Example #1
0
    // Update is called once per frame
    private void Update()
    {
        if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
        {
            mouseControlled = true;
        }
        else if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            mouseControlled = false;
        }

        if (mouseControlled)
        {
            _cursorPosition = MouseOperations.GetCursorPosition();
        }
        else
        {
            _cursorPosition.X += (int)(Input.GetAxis("Horizontal") * Game.Config.MapMouseEmulationSpeed);
            _cursorPosition.Y -= (int)(Input.GetAxis("Vertical") * Game.Config.MapMouseEmulationSpeed);

            MouseOperations.SetCursorPosition(_cursorPosition);
        }

        if (Input.GetAxis("Fire1") != 0 || Input.GetAxis("Submit") != 0)
        {
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp | MouseOperations.MouseEventFlags.LeftDown);
        }
    }
Example #2
0
        public static void LinearSmoothMove(Point newPosition, int steps)
        {
            MouseOperations.MousePoint start = MouseOperations.GetCursorPosition();
            Point  p         = new Point(start.X, start.Y);
            PointF iterPoint = p;

            // Find the slope of the line segment defined by start and newPosition
            PointF slope = new PointF(newPosition.X - start.X, newPosition.Y - start.Y);

            // Divide by the number of steps
            slope.X = slope.X / steps;
            slope.Y = slope.Y / steps;

            // Move the mouse to each iterative point.
            for (int i = 0; i < steps; i++)
            {
                iterPoint = new PointF(iterPoint.X + slope.X, iterPoint.Y + slope.Y);

                MouseOperations.MousePoint o = new MouseOperations.MousePoint((int)iterPoint.X, (int)iterPoint.Y);
                MouseOperations.SetCursorPosition(o);
                Thread.Sleep(1);
            }

            // Move the mouse to the final destination.
            MouseOperations.SetCursorPosition(newPosition.X, newPosition.Y);
        }
Example #3
0
        public static void MoveOne(int num, int delay)
        {
            var pos = MouseOperations.GetCursorPosition();

            SendKeys.Send(num.ToString());
            SendKeys.Flush();
            Clicker.LeftClick(pos.X, pos.Y, delay);
        }
Example #4
0
        public Form1()
        {
            InitializeComponent();
            this.TouchDown += MainWindow_TouchEvent;
            //DoMouseClick();
            MousePoint foo = MouseOperations.GetCursorPosition();

            SavedPoint.X = foo.X;
            SavedPoint.Y = foo.Y;
        }
Example #5
0
        static void aTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            Console.WriteLine("Click..");
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);

            MouseOperations.MousePoint point = MouseOperations.GetCursorPosition();
            point.X = point.X + (isPositive ? mouseSteps : -1 * mouseSteps);
            //point.Y = point.Y +(isPositive ? mouseSteps : -mouseSteps);
            isPositive = !isPositive;
            MouseOperations.SetCursorPosition(point);
        }
        public void DrawHighlight(bool force = false)
        {
            var lastPos = mouse.lastPoint;
            var curPos  = mouse.GetCursorPosition();

            if (mouse.Compare(lastPos, curPos) == 0 && !force)
            {
                return;
            }
            using (Graphics g = Graphics.FromHwnd(this.Handle))
            {
                g.Clear(TRANSPARENT_COLOR);
                g.FillEllipse(MouseBrush, curPos.X - EllipseRadius, curPos.Y - EllipseRadius, EllipseRadius * 2, EllipseRadius * 2);
            }
        }
        private void InitLongPress()
        {
            Task.Run(async() =>
            {
                await Task.Delay(2000);

                if (_isLeftHeldDown)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        LongClick(new LongClickArgs(MouseOperations.GetCursorPosition().X,
                                                    MouseOperations.GetCursorPosition().Y));
                    }));
                }
            });
        }
Example #8
0
        public static void MoveTile(byte tileIndex, byte boardIndex)
        {
            // Get current cursor position
            MouseOperations.MousePoint startPos = MouseOperations.GetCursorPosition();
            //userpb1.Top = 300;
            //userpb1.Left = 800;

            Form form  = Program.MainView;
            int  formX = form.DesktopLocation.X;
            int  formY = form.DesktopLocation.Y;

            // Tile 1
            MouseOperations.SetCursorPosition(formX + 810 + tileIndex * 49, formY + 350);
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
            MouseOperations.SetCursorPosition(formX + 30 + boardIndex % 15 * 50, formY + 80 + boardIndex / 15 * 50);
            MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
            Application.DoEvents();

            MouseOperations.SetCursorPosition(startPos);
        }