Ejemplo n.º 1
0
 private void ProcessPossibleDoubleClick(ref MouseEventExtArgs e)
 {
     if (IsDoubleClick(e.Button, e.Timestamp))
     {
         e = e.ToDoubleClickEventArgs();
         m_DownButtonsWaitingForMouseUp = MouseButtons.None;
         m_PreviousClicked     = MouseButtons.None;
         m_PreviousClickedTime = 0;
     }
     else
     {
         m_DownButtonsWaitingForMouseUp |= e.Button;
         m_PreviousClickedTime           = e.Timestamp;
     }
 }
Ejemplo n.º 2
0
        private void ProcessMouseDown(ref MouseEventExtArgs e)
        {
            if (IsGlobal)
            {
                ProcessPossibleDoubleClick(ref e);
            }
            else
            {
                // These are only used for global. No need for them in AppHooks
                m_DownButtonsWaitingForMouseUp = MouseButtons.None;
                m_PreviousClicked     = MouseButtons.None;
                m_PreviousClickedTime = 0;
            }


            InvokeMouseEventHandler(MouseDown, e);
            InvokeMouseEventHandlerExt(MouseDownExt, e);
            if (e.Handled)
            {
                SetSupressButtonUpFlag(e.Button);
                e.Handled = true;
            }
        }
Ejemplo n.º 3
0
        //##################################################################
        #region ProcessCallback and related subroutines

        /// <summary>
        /// This method processes the data from the hook and initiates event firing.
        /// </summary>
        /// <param name="wParam">The first Windows Messages parameter.</param>
        /// <param name="lParam">The second Windows Messages parameter.</param>
        /// <returns>
        /// True - The hook will be passed along to other applications.
        /// <para>
        /// False - The hook will not be given to other applications, effectively blocking input.
        /// </para>
        /// </returns>
        protected override bool ProcessCallback(int wParam, IntPtr lParam)
        {
            MouseEventExtArgs e = MouseEventExtArgs.FromRawData(wParam, lParam, IsGlobal);

            if (e.IsMouseKeyDown)
            {
                ProcessMouseDown(ref e);
            }

            if (e.Clicks == 1 && e.IsMouseKeyUp && !e.Handled)
            {
                ProcessMouseClick(ref e);
            }

            if (e.Clicks == 2 && !e.Handled)
            {
                InvokeMouseEventHandler(MouseDoubleClick, e);
            }

            if (e.IsMouseKeyUp)
            {
                ProcessMouseUp(ref e);
            }

            if (e.WheelScrolled)
            {
                InvokeMouseEventHandler(MouseWheel, e);
            }

            if (HasMoved(e.Point))
            {
                ProcessMouseMove(ref e);
            }

            return(!e.Handled);
        }
        private void ProcessMouseMove(ref MouseEventExtArgs e)
        {
            m_PreviousPosition = e.Point;

            InvokeMouseEventHandler(MouseMove, e);
            InvokeMouseEventHandlerExt(MouseMoveExt, e);
        }
        private void ProcessMouseDown(ref MouseEventExtArgs e)
        {
            if (IsGlobal)
            {
                ProcessPossibleDoubleClick(ref e);
            }
            else
            {
                // These are only used for global. No need for them in AppHooks
                m_DownButtonsWaitingForMouseUp = MouseButtons.None;
                m_PreviousClicked = MouseButtons.None;
                m_PreviousClickedTime = 0;
            }

            InvokeMouseEventHandler(MouseDown, e);
            InvokeMouseEventHandlerExt(MouseDownExt, e);
            if (e.Handled)
            {
                SetSupressButtonUpFlag(e.Button);
                e.Handled = true;
            }
        }
 private void ProcessMouseClick(ref MouseEventExtArgs e)
 {
     if ((m_DownButtonsWaitingForMouseUp & e.Button) != MouseButtons.None)
     {
         m_PreviousClicked = e.Button;
         m_PreviousClickedPosition = e.Point;
         m_DownButtonsWaitingForMouseUp = MouseButtons.None;
         InvokeMouseEventHandler(MouseClick, e);
         InvokeMouseEventHandlerExt(MouseClickExt, e);
     }
 }
 private void InvokeMouseEventHandlerExt(EventHandler<MouseEventExtArgs> handler, MouseEventExtArgs e)
 {
     if (handler != null)
     {
         handler(this, e);
     }
 }
Ejemplo n.º 8
0
 private void OnMouseMove(object sender, MouseEventExtArgs e)
 {
     if (MouseMove != null)
         MouseMove(sender, e);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates <see cref="MouseEventExtArgs"/> from relevant mouse data.
        /// </summary>
        /// <param name="wParam">First Windows Message parameter.</param>
        /// <param name="mouseInfo">A MouseStruct containing information from which to construct MouseEventExtArgs.</param>
        /// <returns>A new MouseEventExtArgs object.</returns>
        private static MouseEventExtArgs FromRawDataUniversal(int wParam, MouseStruct mouseInfo)
        {
            MouseButtons button     = MouseButtons.None;
            short        mouseDelta = 0;
            int          clickCount = 0;

            bool isMouseKeyDown = false;
            bool isMouseKeyUp   = false;


            switch (wParam)
            {
            case Messages.WM_LBUTTONDOWN:
                isMouseKeyDown = true;
                button         = MouseButtons.Left;
                clickCount     = 1;
                break;

            case Messages.WM_LBUTTONUP:
                isMouseKeyUp = true;
                button       = MouseButtons.Left;
                clickCount   = 1;
                break;

            case Messages.WM_LBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = MouseButtons.Left;
                clickCount     = 2;
                break;

            case Messages.WM_RBUTTONDOWN:
                isMouseKeyDown = true;
                button         = MouseButtons.Right;
                clickCount     = 1;
                break;

            case Messages.WM_RBUTTONUP:
                isMouseKeyUp = true;
                button       = MouseButtons.Right;
                clickCount   = 1;
                break;

            case Messages.WM_RBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = MouseButtons.Right;
                clickCount     = 2;
                break;

            case Messages.WM_MBUTTONDOWN:
                isMouseKeyDown = true;
                button         = MouseButtons.Middle;
                clickCount     = 1;
                break;

            case Messages.WM_MBUTTONUP:
                isMouseKeyUp = true;
                button       = MouseButtons.Middle;
                clickCount   = 1;
                break;

            case Messages.WM_MBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = MouseButtons.Middle;
                clickCount     = 2;
                break;

            case Messages.WM_MOUSEWHEEL:
                mouseDelta = mouseInfo.MouseData;
                break;

            case Messages.WM_XBUTTONDOWN:
                button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 :
                         MouseButtons.XButton2;
                isMouseKeyDown = true;
                clickCount     = 1;
                break;

            case Messages.WM_XBUTTONUP:
                button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 :
                         MouseButtons.XButton2;
                isMouseKeyUp = true;
                clickCount   = 1;
                break;

            case Messages.WM_XBUTTONDBLCLK:
                isMouseKeyDown = true;
                button         = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 :
                                 MouseButtons.XButton2;
                clickCount = 2;
                break;
            }

            var e = new MouseEventExtArgs(
                button,
                clickCount,
                mouseInfo.Point,
                mouseDelta,
                mouseInfo.Timestamp,
                isMouseKeyDown,
                isMouseKeyUp);

            return(e);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates <see cref="MouseEventExtArgs"/> from relevant mouse data. 
        /// </summary>
        /// <param name="wParam">First Windows Message parameter.</param>
        /// <param name="mouseInfo">A MouseStruct containing information from which to construct MouseEventExtArgs.</param>
        /// <returns>A new MouseEventExtArgs object.</returns>
        private static MouseEventExtArgs FromRawDataUniversal(int wParam, MouseStruct mouseInfo)
        {
            MouseButtons button = MouseButtons.None;
            short mouseDelta = 0;
            int clickCount = 0;

            bool isMouseKeyDown = false;
            bool isMouseKeyUp = false;

            switch (wParam)
            {
                case Messages.WM_LBUTTONDOWN:
                    isMouseKeyDown = true;
                    button = MouseButtons.Left;
                    clickCount = 1;
                    break;
                case Messages.WM_LBUTTONUP:
                    isMouseKeyUp = true;
                    button = MouseButtons.Left;
                    clickCount = 1;
                    break;
                case Messages.WM_LBUTTONDBLCLK:
                    isMouseKeyDown = true;
                    button = MouseButtons.Left;
                    clickCount = 2;
                    break;
                case Messages.WM_RBUTTONDOWN:
                    isMouseKeyDown = true;
                    button = MouseButtons.Right;
                    clickCount = 1;
                    break;
                case Messages.WM_RBUTTONUP:
                    isMouseKeyUp = true;
                    button = MouseButtons.Right;
                    clickCount = 1;
                    break;
                case Messages.WM_RBUTTONDBLCLK:
                    isMouseKeyDown = true;
                    button = MouseButtons.Right;
                    clickCount = 2;
                    break;
                case Messages.WM_MBUTTONDOWN:
                    isMouseKeyDown = true;
                    button = MouseButtons.Middle;
                    clickCount = 1;
                    break;
                case Messages.WM_MBUTTONUP:
                    isMouseKeyUp = true;
                    button = MouseButtons.Middle;
                    clickCount = 1;
                    break;
                case Messages.WM_MBUTTONDBLCLK:
                    isMouseKeyDown = true;
                    button = MouseButtons.Middle;
                    clickCount = 2;
                    break;
                case Messages.WM_MOUSEWHEEL:
                    mouseDelta = mouseInfo.MouseData;
                    break;
                case Messages.WM_XBUTTONDOWN:
                    button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 :
                                                                         MouseButtons.XButton2;
                    isMouseKeyDown = true;
                    clickCount = 1;
                    break;

                case Messages.WM_XBUTTONUP:
                    button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 :
                                                                         MouseButtons.XButton2;
                    isMouseKeyUp = true;
                    clickCount = 1;
                    break;

                case Messages.WM_XBUTTONDBLCLK:
                    isMouseKeyDown = true;
                    button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 :
                                                                         MouseButtons.XButton2;
                    clickCount = 2;
                    break;
            }

            var e = new MouseEventExtArgs(
                button,
                clickCount,
                mouseInfo.Point,
                mouseDelta,
                mouseInfo.Timestamp,
                isMouseKeyDown,
                isMouseKeyUp);

            return e;
        }
Ejemplo n.º 11
0
        private void MouseListener_MouseMoveExt(object sender, MouseEventExtArgs e)
        {
            // Cursor is clipped for one mousemove event to prevent it mysteriously jumping back to previous location after hopping
            if (cursorClipped)
            {
                Cursor.Clip = new Rectangle();
                cursorClipped = false;
            }

            if (!modifierDown && !IsOffScreen)
            {

                #region Handle hovering app

                if (IsForeground && IsHoveringApp)
                {
                    if (mouseLeftApp && !mouseDown)
                    {
                        MoveCursor(CloneToRs(Location, rs.Location, ratio));
                        mouseLeftApp = false;
                    }

                    if (!TopMost)
                    {
                        TopMost = true;
                        HandleMouseMove = true;
                        if (rs.webBrowser1.Document.GetElementsByTagName("applet").Count < 1)
                        {
                            rs.webBrowser1.Document.Focus();
                        }
                    }
                }
                else
                {
                    if (!mouseLeftApp)
                    {
                        mouseLeftApp = true;
                    }
                    if (TopMost)
                    {
                        // Unset TopMost but don't set RS to foreground window in the OnActivated event that changing TopMost calls
                        setForeground = false;
                        TopMost = false;
                        HandleMouseMove = false;
                        setForeground = true;
                    }
                }

                #endregion

                #region Handle hovering rs

                ClickthroughEnabled = IsHoveringRs;

                if (IsForeground && IsHoveringRs)
                {
                    Program.SetMouseSpeed((float)rs.Width / (float)Width);
                    settings.label5.Text = Program.CurrentMouseSpeed.ToString();
                    if (IsResized)
                    {
                        cursor.MoveRelative(Location, rs.Location, ratio);
                    }
                    Program.HideRealCursor = IsResized;
                    HideRsCursor = !IsResized;
                    mouseLeftRs = false;
                    IdleTimerStarted = false;
                }
                else
                {
                    Program.SetMouseSpeed(1);
                    if (!mouseLeftRs && !mouseDown)
                    {
                        MoveCursor(RsToClone(rs.Location, Location, ratio));
                        mouseLeftRs = true;
                    }
                    Program.HideRealCursor = false;
                    HideRsCursor = true;
                    IdleTimerStarted = true;
                }

                #endregion

            }

            #region Handle hovering mini

            if (IsHoveringMini)
            {
                if (!rs.mini.TopMost)
                {
                    rs.mini.TopMost = true;
                }
                Program.HideRealCursor = false;
            }

            #endregion
        }
Ejemplo n.º 12
0
        private void MouseListener_MouseDownExt(object sender, MouseEventExtArgs e)
        {
            if (!mouseDown)
            {
                mouseDown = true;
            }

            if (e.Button == MouseButtons.Left)
            {
                lmbDown = true;
                if (rs.mini != null)
                {
                    lmbDownPos = rs.mini.Location;
                    lmbDownSize = rs.mini.Size;
                }
            }
        }
Ejemplo n.º 13
0
 private void m_MouseHookManager_MouseDownExt_KeyFilter(object sender, MouseEventExtArgs e)
 {
     // Kill right mouse click / context menu
     if (e.Button == MouseButtons.Left) { return; }
     e.Handled = true;
 }
Ejemplo n.º 14
0
 private void m_MouseHookManager_MouseDownExt(object sender, MouseEventExtArgs e)
 {
     e.Handled = true;
 }
Ejemplo n.º 15
0
 private void ProcessMouseUp(ref MouseEventExtArgs e)
 {
     if (!HasSupressButtonUpFlag(e.Button))
     {
         InvokeMouseEventHandler(MouseUp, e);
     }
     else
     {
         RemoveSupressButtonUpFlag(e.Button);
         e.Handled = true;
     }
 }
Ejemplo n.º 16
0
 private void ProcessPossibleDoubleClick(ref MouseEventExtArgs e)
 {
     if (IsDoubleClick(e.Button, e.Timestamp, e.Point))
     {
         e = e.ToDoubleClickEventArgs();
         m_DownButtonsWaitingForMouseUp = MouseButtons.None;
         m_PreviousClicked = MouseButtons.None;
         m_PreviousClickedTime = 0;
     }
     else
     {
         m_DownButtonsWaitingForMouseUp |= e.Button;
         m_PreviousClickedTime = e.Timestamp;
     }
 }
Ejemplo n.º 17
0
 private void HookManager_MouseDownExt(object sender, MouseEventExtArgs e)
 {
     if (e.Button == MouseButtons.Left) { return; }
     e.Handled = true;
     AddLogEntry("Detected "+ e.Button.ToString());
 }
Ejemplo n.º 18
0
 private void InvokeMouseEventHandlerExt(EventHandler <MouseEventExtArgs> handler, MouseEventExtArgs e)
 {
     if (handler != null)
     {
         handler(this, e);
     }
 }
Ejemplo n.º 19
0
 private void HookManager_MouseMoveExt(object sender, MouseEventExtArgs e)
 {
     e.Handled = true;
 }
Ejemplo n.º 20
0
 private void InvokeMouseEventHandlerExt(EventHandler <MouseEventExtArgs> handler, MouseEventExtArgs e)
 {
     handler?.Invoke(this, e);
 }
Ejemplo n.º 21
0
 private void MouseListener_MouseMove(object sender, MouseEventExtArgs e)
 {
     tiempo = 0;
     
 }