# mecount.ps1 - mouse button event counter 2016-07-14
# echo.2ch.net/test/read.cgi/hard/1171295410
$sf = "System.Windows.Forms"
Add-Type -AssemblyName $sf
$f0 = New-Object $sf'.form'
$b = 'Left Middle Right XButton1 XButton2'.Split()
$c = @{}; $b |%{$c.Add($_, 0)}; $d = $c.Clone()
function w {
Write-Host (@("ClickType")+$b -join ", ")
Write-Host (l 'Total' $c)
Write-Host (l 'Double' $d)}
function l ($str, $arr) {return $str+', '+($arr[$b] -join ', ')}
$f0.add_Click({$Global:c[$_.Button.ToString()]++; w})
$f0.add_DoubleClick({$Global:d[$_.Button.ToString()]++; w})
$f0.ShowDialog() |Out-Null