Exemple #1
0
 private int HookProc(int code, int wParam, int lParam)
 {
     if (code < 0)
     {
         return(KeyboardHook.CallNextHookEx(this._hookId, code, wParam, lParam));
     }
     if (wParam == 256 || wParam == 260)
     {
         Keys keys = (Keys)Marshal.ReadInt32((IntPtr)lParam);
         if (this.TargetedKeys.Contains(keys))
         {
             Action <Keys> keyDown = this.KeyDown;
             if (keyDown != null)
             {
                 keyDown(keys);
             }
         }
     }
     return(KeyboardHook.CallNextHookEx(this._hookId, code, wParam, lParam));
 }
Exemple #2
0
 public void Dispose()
 {
     KeyboardHook.UnhookWindowsHookEx(this._hookId);
 }
Exemple #3
0
 private KeyboardHook()
 {
     this.hookCallback = new KeyboardHook.CallbackDelegate(this.HookProc);
     this._hookId      = KeyboardHook.SetWindowsHookEx(13, this.hookCallback, 0, 0);
     this.TargetedKeys = new List <Keys>();
 }
Exemple #4
0
 public HotkeyManager(KeyboardHook hook)
 {
     _hook = hook;
 }