Esempio n. 1
0
 private void OnMouseEvent(MouseHookEventArgs e)
 {
     if (MouseEvent != null)
     {
         MouseEvent(this, e);
     }
 }
Esempio n. 2
0
 private void OnMiddleButtonUp(MouseHookEventArgs e)
 {
     if (MiddleButtonUp != null)
     {
         MiddleButtonUp(this, e);
     }
     OnMouseEvent(e);
 }
Esempio n. 3
0
 private void OnWheel(MouseHookEventArgs e)
 {
     if (Wheel != null)
     {
         Wheel(this, e);
     }
     OnMouseEvent(e);
 }
Esempio n. 4
0
 private void OnRightButtonUp(MouseHookEventArgs e)
 {
     if (RightButtonUp != null)
     {
         RightButtonUp(this, e);
     }
     OnMouseEvent(e);
 }
Esempio n. 5
0
 private void OnLeftButtonUp(MouseHookEventArgs e)
 {
     if (LeftButtonUp != null)
     {
         LeftButtonUp(this, e);
     }
     OnMouseEvent(e);
 }
Esempio n. 6
0
 private void OnMove(MouseHookEventArgs e)
 {
     if (Move != null)
     {
         Move(this, e);
     }
     OnMouseEvent(e);
 }
Esempio n. 7
0
        /// <summary>
        /// This is the callback method that is called whenever a low level mouse event is triggered.
        /// We use it to call our individual custom events.
        /// </summary>
        private IntPtr MouseHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                var lParamStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                var e            = new MouseHookEventArgs(lParamStruct);
                switch ((MouseMessages)wParam)
                {
                case MouseMessages.WmMouseMove:
                    TriggerMouseEvent(e, MouseEventNames.MouseMove, OnMove);
                    break;

                case MouseMessages.WmLButtonDown:
                    TriggerMouseEvent(e, MouseEventNames.LeftButtonDown, OnLeftButtonDown);
                    break;

                case MouseMessages.WmLButtonUp:
                    TriggerMouseEvent(e, MouseEventNames.LeftButtonUp, OnLeftButtonUp);
                    break;

                case MouseMessages.WmRButtonDown:
                    TriggerMouseEvent(e, MouseEventNames.RightButtonDown, OnRightButtonDown);
                    break;

                case MouseMessages.WmRButtonUp:
                    TriggerMouseEvent(e, MouseEventNames.RightButtonUp, OnRightButtonUp);
                    break;

                case MouseMessages.WmMButtonDown:
                    TriggerMouseEvent(e, MouseEventNames.MiddleButtonDown, OnMiddleButtonDown);
                    break;

                case MouseMessages.WmMButtonUp:
                    TriggerMouseEvent(e, MouseEventNames.MouseMove, OnMove);
                    e.MouseEventName = MouseEventNames.MiddleButtonUp;
                    OnMiddleButtonUp(e);
                    break;

                case MouseMessages.WmMouseWheel:
                    TriggerMouseEvent(e, MouseEventNames.MouseMove, OnMove);
                    e.MouseEventName = MouseEventNames.MouseWheel;
                    OnWheel(e);
                    break;
                }
            }
            return(NativeMethods.CallNextHookEx(hookId, nCode, wParam, lParam));
        }
Esempio n. 8
0
 private static void TriggerMouseEvent(MouseHookEventArgs e, MouseEventNames name, Action <MouseHookEventArgs> method)
 {
     e.MouseEventName = name;
     method(e);
 }