Esempio n. 1
0
 private IntPtr KeyBoardCallBack(int code, IntPtr wParam, IntPtr lParam)
 {
     if (code < 0)
     {
         return(WindowsNativeMethods.CallNextHookEx(KeyBoardHandle, code, wParam, lParam));
     }
     KeyBoardPressed?.Invoke(this, new EventArgs());
     return(WindowsNativeMethods.CallNextHookEx(KeyBoardHandle, code, wParam, lParam));
 }
Esempio n. 2
0
 private IntPtr MouseCallBack(int code, IntPtr wParam, IntPtr lParam)
 {
     if (code < 0)
     {
         return(WindowsNativeMethods.CallNextHookEx(MouseHandle, code, wParam, lParam));
     }
     MouseMoved?.Invoke(this, new EventArgs());
     return(WindowsNativeMethods.CallNextHookEx(MouseHandle, code, wParam, lParam));
 }
Esempio n. 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (KeyBoardHandle != IntPtr.Zero)
         {
             WindowsNativeMethods.UnhookWindowsHookEx(
                 KeyBoardHandle);
         }
         disposedValue = true;
     }
 }
Esempio n. 4
0
 public UserKeyBoard()
 {
     KeyBoardProc   = KeyBoardCallBack;
     KeyBoardHandle = WindowsNativeMethods.SetWindowsHookEx(HookCodes.HookType.WH_KEYBOARD_LL, KeyBoardProc, IntPtr.Zero, 0);
 }
Esempio n. 5
0
 public UserMouse()
 {
     MouseProc   = MouseCallBack;
     MouseHandle = WindowsNativeMethods.SetWindowsHookEx(HookCodes.HookType.WH_MOUSE_LL, MouseProc, IntPtr.Zero, 0);
 }