Beispiel #1
0
        private IntPtr MouseHookDelegate(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code < 0)
            {
                return(WindowsHookHelper.CallNextHookEx(mouseHandle, code, wParam, lParam));
            }

            MouseMoved?.Invoke(this, new EventArgs());

            return(WindowsHookHelper.CallNextHookEx(mouseHandle, code, wParam, lParam));
        }
Beispiel #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (mouseHandle != IntPtr.Zero)
                {
                    WindowsHookHelper.UnhookWindowsHookEx(mouseHandle);
                }

                disposed = true;
            }
        }
Beispiel #3
0
        private IntPtr KeyboardHookDelegate(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code < 0)
            {
                return(WindowsHookHelper.CallNextHookEx(
                           keyBoardHandle, code, wParam, lParam));
            }

            KeyBoardKeyPressed?.Invoke(this, new EventArgs());

            return(WindowsHookHelper.CallNextHookEx(
                       keyBoardHandle, code, wParam, lParam));
        }
Beispiel #4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MouseInput" /> class.
 /// </summary>
 public MouseInput()
 {
     mouseDelegate = MouseHookDelegate;
     mouseHandle   = WindowsHookHelper.SetWindowsHookEx(WH_MOUSE_LL, mouseDelegate, IntPtr.Zero, 0);
 }
Beispiel #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="KeyboardInput" /> class.
 /// </summary>
 public KeyboardInput()
 {
     keyBoardDelegate = KeyboardHookDelegate;
     keyBoardHandle   = WindowsHookHelper.SetWindowsHookEx(
         WH_KEYBOARD_LL, keyBoardDelegate, IntPtr.Zero, 0);
 }