Ejemplo n.º 1
0
 private IntPtr HookCallback(
     int nCode, IntPtr wParam, IntPtr lParam)
 {
     try
     {
         return(HookCallbackInner(nCode, wParam, lParam));
     }
     catch
     {
         Console.WriteLine("There was some error somewhere...");
     }
     return(InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam));
 }
Ejemplo n.º 2
0
        private IntPtr HookCallbackInner(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                int vkCode = Marshal.ReadInt32(lParam);

                KeyEvent?.Invoke(this, new RawKeyEventArgs(vkCode, false)
                {
                    Type = (int)wParam
                });

                if (IsBlockKeyboard)
                {
                    return((IntPtr)1);
                }
            }
            return(InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam));
        }