// function for hooking the keybind processes public int HookProc(int Code, int wParam, ref keyBoardHookStruct lParam) { if (Code >= 0) { Keys key = (Keys)lParam.vkCode; if (HookedKeys.Contains(key)) { KeyEventArgs kArg = new KeyEventArgs(key); if ((wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) && (KeyDown != null)) { KeyDown(this, kArg); } else if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null)) { KeyUp(this, kArg); } if (kArg.Handled) { return(1); } } } return(CallNextHookEx(Hook, Code, wParam, ref lParam)); }
static extern int CallNextHookEx(IntPtr hhk, int code, int wParam, ref keyBoardHookStruct lParam);