/// <summary> /// Hook process messages. /// </summary> /// <param name="nCode"></param> /// <param name="wParam"></param> /// <param name="lParam"></param> /// <returns></returns> static IntPtr HookProcFunction(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode == 0) { KBLLHOOKSTRUCT pKBLLHOOKSTRUCT = (KBLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBLLHOOKSTRUCT)); switch (wParam.ToInt32()) { case WM_KEYDOWN: KeyboardDown?.Invoke(null, new KeyEventArgs((Keys)pKBLLHOOKSTRUCT.vkCode)); //MessageBox.Show("OKAY, " + pKBLLHOOKSTRUCT.vkCode); // <--- DEBUG break; case WM_KEYUP: KeyboardUp?.Invoke(null, new KeyEventArgs((Keys)pKBLLHOOKSTRUCT.vkCode)); break; default: break; } } return(API.CallNextHookEx(hHook, nCode, wParam, lParam)); }
internal void InvokeKeyboardUp(KeyboardEventArgs args) => KeyboardUp?.Invoke(this, args);