Exemplo n.º 1
0
        public override void MoveToAndClick(int x, int y, Button ButtonToClick, double speed = SpeedDefault)
        {
            Point destination      = new Point(x, y);
            Point current_location = new Point();
            bool  clicked          = false;

            // break out of loop if it clicked regardless of location because
            // the cursor may have moved during the click
            while ((current_location = Location) != destination && !clicked)
            {
                int dx = x - current_location.X;
                int dy = y - current_location.Y;

                SerializableCursorPath PathToUse = null;
                try
                {
                    PathToUse = Paths.GetRandomSuitablePath(dx, dy);
                }
                catch
                {
                    BackupMethod.MoveToAndClick(x, y, ButtonToClick, speed);
                    return;
                }

                clicked = MoveCursorUsingPath(PathToUse, dx, dy, speed, ButtonToClick,
                                              new Rectangle(x, y, 1, 1));
            }
        }
Exemplo n.º 2
0
        bool MoveCursorUsingPath(SerializableCursorPath path, int dx, int dy, double speed = SpeedDefault, Button ButtonToClick = null,
                                 Rectangle?OnlyClickWithin = null)
        {
            // if currently on same axis as destination, then use 1.0 for the scale
            // this may move your cursor off of the axis, but the next move should put you
            // in the correct spot
            double scale_x = (dx == 0 || path.Destination.X == 0 ? 1.0 : (double)dx / path.Destination.X);
            double scale_y = (dy == 0 || path.Destination.Y == 0 ? 1.0 : (double)dy / path.Destination.Y);

            /*double path_displacement_magnitude = Math.Sqrt(path.Destination.X * path.Destination.X +
             *  path.Destination.Y * path.Destination.Y);
             * double path_speed = (path_displacement_magnitude / path.MouseDownTime) * 1000;
             * double scale_speed = speed / path_speed;*/

            double scale_speed = speed / SpeedDefault;

            return(FollowPath(path.Path, scale_x, scale_y, scale_speed,
                              path.MouseDownTime, ButtonToClick));
        }
Exemplo n.º 3
0
 public void Add(SerializableCursorPath item)
 {
     Paths.Add(item);
 }