private int HookCallback(int code, IntPtr wParam, ref KeyboardHook.KBDLLHOOKSTRUCT lParam) { if (code < 0) { return KeyboardHook.CallNextHookEx(this._hookHandle, code, wParam, ref lParam); } if ((lParam.flags & 128u) != 0u && this.KeyUp != null) { this.KeyUp(this, new HookEventArgs(lParam.vkCode)); } if ((lParam.flags & 128u) == 0u && this.KeyDown != null) { this.KeyDown(this, new HookEventArgs(lParam.vkCode)); } return KeyboardHook.CallNextHookEx(this._hookHandle, code, wParam, ref lParam); }
private static extern int CallNextHookEx(IntPtr hook, int code, IntPtr wParam, ref KeyboardHook.KBDLLHOOKSTRUCT lParam);
private static extern IntPtr SetWindowsHookEx(KeyboardHook.HookType code, KeyboardHook.HookProc func, IntPtr instance, int threadID);
public App() { this.hook = new KeyboardHook(); this.hook.KeyDown += new KeyboardHook.HookEventHandler(this.OnHookKeyDown); }