Beispiel #1
0
        private void LinearSmoothMove(Point newPosition)
        {
            Random rnd = new Random();

            var    mpoint    = MouseOperations.GetCursorPosition();
            Point  start     = new Point(mpoint.X, mpoint.Y);
            PointF iterPoint = start;


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

            var steps = Math.Max(Math.Abs(slope.X), Math.Abs(slope.Y));

            // Divide by the number of steps
            slope.X /= steps;
            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);
                var misleadinpoint = Point.Round(new PointF(iterPoint.X + 1, iterPoint.Y + 1));
                MouseOperations.SetCursorPosition(misleadinpoint.X, misleadinpoint.Y);
                Thread.Sleep(1);
            }

            // Move the mouse to the final destination.
            MouseOperations.SetCursorPosition(newPosition.X, newPosition.Y);
        }
Beispiel #2
0
        public void MoveMouseWithVisible(Point newPos)
        {
            Random rnd = new Random();

            var mpoint      = MouseOperations.GetCursorPosition();
            var originalPos = new Point(mpoint.X, mpoint.Y);

            var firstPoint = new Point(originalPos.X + rnd.Next(15, 45), originalPos.Y + rnd.Next(15, 45));
            var secondPos  = new Point(
                ((originalPos.X + newPos.X) / 2) + rnd.Next(15, 45),
                ((originalPos.Y + newPos.Y) / 2) + rnd.Next(15, 45));
            var thirdPoint = new Point(newPos.X + rnd.Next(15, 45), newPos.Y + rnd.Next(100, 150));

            LinearSmoothMove(firstPoint);
            LinearSmoothMove(secondPos);
            LinearSmoothMove(thirdPoint);
            LinearSmoothMove(newPos);
        }