Example #1
0
        private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                if (wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYDOWN ||
                    wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYUP ||
                    wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYDOWN ||
                    wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYUP)
                {
                    hookedKeyboardCallbackAsync.BeginInvoke((InterceptKeys.KeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), null, null);
                }
            }

            return(InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam));
        }
Example #2
0
 /// <summary>
 /// Creates global keyboard listener
 /// </summary>
 public KeyboardListener()
 {
     hookedLowLevelKeyboardProc = (InterceptKeys.LowLevelKeyboardProc)LowLevelKeyboardProc;
     hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);
     hookedKeyboardCallbackAsync = new KeyboardCallbackAsync(KeyboardListener_KeyboardCallbackAsync);
 }
Example #3
0
 /// <summary>
 /// Disposes the hook
 /// <remarks>This call is required as it calls the UnhookWindowsHookEx</remarks>
 /// </summary>
 public void Dispose()
 {
     InterceptKeys.UnhookWindowsHookEx(hookId);
 }