Skip to content

Instantly share code, notes, and snippets.

@whamtet
Last active June 23, 2023 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whamtet/b1e1ab9370456ebf675810a3d9c39943 to your computer and use it in GitHub Desktop.
Save whamtet/b1e1ab9370456ebf675810a3d9c39943 to your computer and use it in GitHub Desktop.
import java.awt.*;
import java.time.LocalDateTime;
public class MouseMover {
public static final int PAUSE = 20000;
public static void main(String... args) throws Exception {
int limit = args.length == 0 ? 24 : Integer.parseInt(args[0]);
System.out.println("Time limit: " + limit);
Robot robot = new Robot();
int increment = 1;
while (LocalDateTime.now().getHour() < limit) {
increment *= -1;
Point p = MouseInfo.getPointerInfo().getLocation();
robot.mouseMove(p.x + increment, p.y + increment);
Thread.sleep(PAUSE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment