You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using namespace System.Windows.Forms
using namespace h.hooks
Add-Type -Path .\H.Hooks.dll
Add-Type -AssemblyName System.Windows.Forms
$mh = New-Object LowLevelMouseHook
$frm = New-Object Form
#$mh.add_Down({Write-Host "test"}) //(a) does not work, but need this. Sometimes PS crashes
Register-ObjectEvent -InputObject $mh -EventName Down -Action {Write-Host "test"} // (b) does work
$mh.start()
$frm.showdialog()
Method (b)'s callback approach only works in a timely fashion while PowerShell is in control of the foreground thread, which is not the case here, because the $frm.showdialog() call blocks it. Therefore, method (a) must be used.
Describe the bug
Method (b)'s callback approach only works in a timely fashion while PowerShell is in control of the foreground thread, which is not the case here, because the $frm.showdialog() call blocks it. Therefore, method (a) must be used.
Steps to reproduce the bug
See example in description. More info about powershell handling events
Expected behavior
No response
Screenshots
No response
NuGet package version
No response
Platform
Windows Forms
IDE
Other
Additional context
Powershell
The text was updated successfully, but these errors were encountered: