protected virtual void OnHookEvent(HookEventArgs hookArgs, KeyBoardInfo keyBoardInfo) { if (HookEvent != null) { HookEvent(hookArgs, keyBoardInfo); } }
private int HookProcedure(int code, IntPtr wParam, IntPtr lParam) { KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT)); if (code < 0) { return(CallNextHookEx(hookDeleg, code, wParam, lParam)); } // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.Code = code; e.wParam = wParam; e.lParam = lParam; KeyBoardInfo keyInfo = new KeyBoardInfo(); keyInfo.vkCode = hookStruct.vkCode; keyInfo.scanCode = hookStruct.scanCode; OnHookEvent(e, keyInfo); // Yield to the next hook in the chain return(CallNextHookEx(hookDeleg, code, wParam, lParam)); }