Beispiel #1
0
        private int LowLevelKeyboardProc(int nCode, int wParam, ref ShortcutsWinApi.keyBoardHookStruct lParam)
        {
            if (nCode >= 0)
            {
                KeyEventArgs eventArg = new KeyEventArgs((Keys)lParam.vkCode);
                switch (wParam)
                {
                case ShortcutsWinApi.WM_KEYDOWN:
                case ShortcutsWinApi.WM_SYSKEYDOWN:
                    KeyDown(eventArg);
                    break;

                case ShortcutsWinApi.WM_KEYUP:
                case ShortcutsWinApi.WM_SYSKEYUP:
                    KeyUp(eventArg);
                    break;
                }

                if (eventArg.Handled)
                {
                    return(1);
                }
            }
            return(ShortcutsWinApi.CallNextHookEx(IntPtr.Zero, nCode, wParam, ref lParam));
        }
Beispiel #2
0
 public Shortcuts()
 {
     callback            = LowLevelKeyboardProc;
     hookProcedureHandle = ShortcutsWinApi.SetWindowsHookEx(ShortcutsWinApi.WH_KEYBOARD_LL, callback, IntPtr.Zero, 0);
 }