private void OnKeyboardKeyEvent(KeyboardHookEventArgs e) { if (KeyBoardKeyEvent != null) { KeyBoardKeyEvent(this, e); } }
/// <summary> /// This is the call-back method that is called whenever a keyboard event is triggered. /// We use it to call our individual custom events. /// </summary> private IntPtr KeyboardHookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (!Enabled) { return(HelperMethods.CallNextHookEx(hookId, nCode, wParam, lParam)); } if (nCode >= 0) { var lParamStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct)); var e = new KeyboardHookEventArgs(lParamStruct); switch ((KeyboardMessages)wParam) { case KeyboardMessages.WmSyskeydown: case KeyboardMessages.WmKeydown: e.KeyboardEventName = KeyboardEventNames.KeyDown; OnKeyboardKeyDown(e); break; case KeyboardMessages.WmSyskeyup: case KeyboardMessages.WmKeyup: e.KeyboardEventName = KeyboardEventNames.KeyUp; OnKeyboardKeyUp(e); break; } if (e.Handled) { return((IntPtr)(-1)); } } return(HelperMethods.CallNextHookEx(hookId, nCode, wParam, lParam)); }
private void OnKeyboardKeyDown(KeyboardHookEventArgs e) { if (KeyBoardKeyDown != null) { KeyBoardKeyDown(this, e); } OnKeyboardKeyEvent(e); }