Can this be used in powershell ?

Oct 30, 2015 at 3:25 PM
Hi all,

I would like to know if we can use mouse hook in powershell ?
I have tried this code but it doesn't work :
$dll="mypath\MouseKeyboardActivityMonitor.dll"
[Reflection.Assembly]::LoadFile($dll) | out-null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null


$GlobalHook=New-Object MouseKeyboardActivityMonitor.WinApi.GlobalHooker
$MouseHook=New-Object MouseKeyboardActivityMonitor.MouseHookListener($GlobalHook)


Register-ObjectEvent -InputObject $MouseHook -EventName "MouseClickExt" -Action {[System.Windows.Forms.MessageBox]::Show("Click !")}

$MouseHook.start()
Nothing append when i click. I have no error message. I have also tryied with a "Wait-event" at the end but it's the same.

Thank you.