Method WindowsHook.Keyboard
Overload
Sets a low-level keyboard hook (WH_KEYBOARD_LL). See API SetWindowsHookEx.
public static WindowsHook Keyboard(Action<HookData.Keyboard> hookProc, bool ignoreAuInjected = true, bool setNow = true)
Parameters
hookProc (Action<HookData.Keyboard>)
The hook procedure (function that handles hook events).
Must return as soon as possible. More info: WindowsHook.LowLevelHooksTimeout.
If calls HookData.Keyboard.BlockEvent or HookData.ReplyMessage noteWhen the hook procedure returns, the parameter variable becomes invalid and unsafe to use. If you need the data for later use, copy its properties and not whole variable. |
ignoreAuInjected (bool)
Don't call the hook procedure for events sent by functions of this library. Default |
setNow (bool)
Set hook now. Default |
Returns
WindowsHook
New WindowsHook object that manages the hook. |
Exceptions
AuException
Failed. |
Examples
var stop = false;
using var hook = WindowsHook.Keyboard(x => {
print.it(x);
if(x.vkCode == KKey.Escape) { stop = true; x.BlockEvent(); }
});
dialog.show("hook");
//or
//wait.doEventsUntil(-10, () => stop); //wait max 10 s for Esc key
//print.it("the end");