Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        public void SendMouseEvent(int x, int y, MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;

            Point point = ConvertDevicePoint(x, y);

            stroke.Mouse.X     = point.X;
            stroke.Mouse.Y     = point.Y;
            stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

            InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
        }
Пример #2
0
        public void SendMouseEvent(MouseStroke mouseStroke, int device)
        {
            Stroke stroke = new Stroke();

            stroke.Mouse = mouseStroke;
            InterceptionDriver.Send(context, device, ref stroke, 1);
        }
Пример #3
0
        public void SendMouseEvent(MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke
            {
                State = state
            };

            mouseStroke.Rolling = (short)(state == MouseState.ScrollUp ? 120 : state == MouseState.ScrollDown ? -120 : mouseStroke.Rolling);

            stroke.Mouse = mouseStroke;

            InterceptionDriver.Send(Context, 12, ref stroke, 1);
        }
Пример #4
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// Fixed it by using a Convertion!
        /// </summary>
        ///
        public void MoveMouseTo(int x, int y)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();
            Point       mousecoord  = ConvertDevicePoint(x, y);

            mouseStroke.X = mousecoord.X;
            mouseStroke.Y = mousecoord.Y;

            stroke.Mouse       = mouseStroke;
            stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

            InterceptionDriver.Send(context, MOUSEID, ref stroke, 1);
        }
Пример #5
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to get the current cursor's position, calculates the desired destination's offset, and uses the Win32 API to set the cursor to the new position.
        /// </summary>
        public void MoveMouseBy(int deltaX, int deltaY)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();
            Point       mousecoord  = ConvertDevicePoint(deltaX, deltaY);

            mouseStroke.X = mousecoord.X;
            mouseStroke.Y = mousecoord.Y;

            stroke.Mouse       = mouseStroke;
            stroke.Mouse.Flags = MouseFlags.MoveRelative;

            InterceptionDriver.Send(context, MOUSEID, ref stroke, 1);
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        public void SendMouseEvent(MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;
            InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
        }
Пример #7
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// </summary>
        public void MoveMouseTo(int x, int y, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = x;
                mouseStroke.Y = y;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

                InterceptionDriver.Send(context, 12, ref stroke, 1);
            }
            {
                Cursor.Position = new Point(x, y);
            }
        }
Пример #8
0
        internal void SendMouseEvent(MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            ////if (state == MouseState.Wheel)
            ////{
            ////    mouseStroke.Rolling = 120;
            ////}
            ////else if (state == MouseState.ScrollDown)
            ////{
            ////    mouseStroke.Rolling = -120;
            ////}

            stroke.Mouse = mouseStroke;

            this.Send(this.context, 12, ref stroke, 1);
        }
Пример #9
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// </summary>
        public void MoveMouseTo(int x, int y, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = x;
                mouseStroke.Y = y;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

                InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
                this.debug("Move mouse to " + x + ", " + y + " for device id " + mouseDeviceId);
            }
            {
                Cursor.Position = new Point(x, y);
            }
        }
Пример #10
0
        public void SendMouseEvent(MouseState state)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;

            InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
            this.debug("Send mouse state " + state.ToString() + " for device id " + mouseDeviceId);
        }
Пример #11
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to get the current cursor's position, calculates the desired destination's offset, and uses the Win32 API to set the cursor to the new position.
        /// </summary>
        public void MoveMouseBy(int deltaX, int deltaY, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = deltaX;
                mouseStroke.Y = deltaY;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveRelative;

                InterceptionDriver.Send(context, 12, ref stroke, 1);
            }
            else
            {
                var currentPos = Cursor.Position;
                Cursor.Position = new Point(currentPos.X + deltaX, currentPos.Y - deltaY); // Coordinate system for y: 0 begins at top, and bottom of screen has the largest number
            }
        }
Пример #12
0
        public void SendMouseEvent(MouseState state, ushort information = 0)
        {
            Stroke      stroke      = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State       = state;
            mouseStroke.Information = information;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;

            InterceptionDriver.Send(context, 12, ref stroke, 1);
        }
Пример #13
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// </summary>
        public void MoveMouseTo(int x, int y, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke      stroke      = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                Point point = ConvertDevicePoint(x, y);

                mouseStroke.X     = point.X;
                mouseStroke.Y     = point.Y;
                mouseStroke.State = 0;

                stroke.Mouse       = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveAbsolute;
                InterceptionDriver.Send(context, mouseDeviceId, ref stroke, 1);
            }
            else
            {
                Cursor.Position = new Point(x, y);
            }
        }
Пример #14
0
        public void SendMouseEvent(MouseState state)
        {
            Stroke stroke = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.State = state;

            if (state == MouseState.ScrollUp)
            {
                mouseStroke.Rolling = 120;
            }
            else if (state == MouseState.ScrollDown)
            {
                mouseStroke.Rolling = -120;
            }

            stroke.Mouse = mouseStroke;

            InterceptionDriver.Send(context, 12, ref stroke, 1);
        }
Пример #15
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to set the cursor's position and does not use the driver.
        /// </summary>
        public void MoveMouseTo(int x, int y, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke stroke = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = x;
                mouseStroke.Y = y;

                stroke.Mouse = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveAbsolute;

                InterceptionDriver.Send(context, 12, ref stroke, 1);
            }
            {
                Cursor.Position = new Point(x, y);
            }
        }
Пример #16
0
        /// <summary>
        /// Warning: This function, if using the driver, does not function reliably and often moves the mouse in unpredictable vectors. An alternate version uses the standard Win32 API to get the current cursor's position, calculates the desired destination's offset, and uses the Win32 API to set the cursor to the new position.
        /// </summary>
        public void MoveMouseBy(int deltaX, int deltaY, bool useDriver = false)
        {
            if (useDriver)
            {
                Stroke stroke = new Stroke();
                MouseStroke mouseStroke = new MouseStroke();

                mouseStroke.X = deltaX;
                mouseStroke.Y = deltaY;

                stroke.Mouse = mouseStroke;
                stroke.Mouse.Flags = MouseFlags.MoveRelative;

                InterceptionDriver.Send(context, 12, ref stroke, 1);
            }
            else
            {
                var currentPos = Cursor.Position;
                Cursor.Position = new Point(currentPos.X + deltaX, currentPos.Y - deltaY); // Coordinate system for y: 0 begins at top, and bottom of screen has the largest number
            }
        }
Пример #17
0
        private List <KeyInfo> GetMouseKeys(MouseStroke stroke)
        {
            var keys = new List <KeyInfo>();

            foreach (MouseState mouseState in Enum.GetValues(typeof(MouseState)))
            {
                if (stroke.State.HasFlag(mouseState))
                {
                    switch (mouseState)
                    {
                    case MouseState.None:
                        break;

                    case MouseState.LeftDown:
                        keys.Add(new KeyInfo(InterceptionKey.MouseLeftButton, true));
                        break;

                    case MouseState.LeftUp:
                        keys.Add(new KeyInfo(InterceptionKey.MouseLeftButton, false));
                        break;

                    case MouseState.RightDown:
                        keys.Add(new KeyInfo(InterceptionKey.MouseRightButton, true));
                        break;

                    case MouseState.RightUp:
                        keys.Add(new KeyInfo(InterceptionKey.MouseRightButton, false));
                        break;

                    case MouseState.MiddleDown:
                        keys.Add(new KeyInfo(InterceptionKey.MouseMiddleButton, true));
                        break;

                    case MouseState.MiddleUp:
                        keys.Add(new KeyInfo(InterceptionKey.MouseMiddleButton, false));
                        break;

                    case MouseState.LeftExtraDown:
                        keys.Add(new KeyInfo(InterceptionKey.MouseExtraLeft, true));
                        break;

                    case MouseState.LeftExtraUp:
                        keys.Add(new KeyInfo(InterceptionKey.MouseExtraLeft, false));
                        break;

                    case MouseState.RightExtraDown:
                        keys.Add(new KeyInfo(InterceptionKey.MouseExtraRight, true));
                        break;

                    case MouseState.RightExtraUp:
                        keys.Add(new KeyInfo(InterceptionKey.MouseExtraRight, false));
                        break;

                    case MouseState.Wheel:
                        if (stroke.Rolling > 0)
                        {
                            keys.Add(new KeyInfo(InterceptionKey.MouseWheelUp, true));
                        }
                        else if (stroke.Rolling < 0)
                        {
                            keys.Add(new KeyInfo(InterceptionKey.MouseWheelDown, true));
                        }

                        break;

                    case MouseState.HWheel:
                        if (stroke.Rolling > 0)
                        {
                            keys.Add(new KeyInfo(InterceptionKey.MouseWheelRight, true));
                        }
                        else if (stroke.Rolling < 0)
                        {
                            keys.Add(new KeyInfo(InterceptionKey.MouseWheelLeft, true));
                        }

                        break;

                    default:
                        break;
                    }
                }
            }

            if (stroke.X < -Interception.MouseMoveDeadZone)
            {
                keys.Add(new KeyInfo(InterceptionKey.MouseMoveLeft, true));
                this.ReleaseKeyWithDelay(this.currentDevice, InterceptionKey.MouseMoveLeft, this.mouseMoveAutoOffDelay);
            }
            else if (stroke.X > Interception.MouseMoveDeadZone)
            {
                keys.Add(new KeyInfo(InterceptionKey.MouseMoveRight, true));
                this.ReleaseKeyWithDelay(this.currentDevice, InterceptionKey.MouseMoveRight, this.mouseMoveAutoOffDelay);
            }

            if (stroke.Y < -Interception.MouseMoveDeadZone)
            {
                keys.Add(new KeyInfo(InterceptionKey.MouseMoveUp, true));
                this.ReleaseKeyWithDelay(this.currentDevice, InterceptionKey.MouseMoveUp, this.mouseMoveAutoOffDelay);
            }
            else if (stroke.Y > Interception.MouseMoveDeadZone)
            {
                keys.Add(new KeyInfo(InterceptionKey.MouseMoveDown, true));
                this.ReleaseKeyWithDelay(this.currentDevice, InterceptionKey.MouseMoveDown, this.mouseMoveAutoOffDelay);
            }

            return(keys);
        }
Пример #18
0
        public void MoveMouseBy(int deltaX, int deltaY)
        {
            Stroke stroke = new Stroke();
            MouseStroke mouseStroke = new MouseStroke();

            mouseStroke.X = deltaX;
            mouseStroke.Y = deltaY;

            stroke.Mouse = mouseStroke;
            stroke.Mouse.Flags = MouseFlags.MoveRelative;

            InterceptionDriver.Send(context, 12, ref stroke, 1);
        }