Auto mouse mover - Java code
The Auto Mouse Mover program automatically moves your mouse without any human input, preventing your computer from going into sleep mode or logging off. This tool is especially useful when running automation scripts or tasks on your desktop, ensuring your system stays active and doesn’t enter idle mode.
You can easily save and run the Java program below whenever needed. No third-party software installations are required—just run the code, and your computer stays active.
package com.bhuvaneswaran;
import java.awt.Robot;
import java.util.Random;
public class MouseMovement {
public static final int FIVE_SECONDS = 5000;
public static final int MAX_Y = 400;
public static final int MAX_X = 400;
public static void main(String... args) throws Exception {
Robot robot = new Robot();
Random random = new Random();
while (true) {
robot.mouseMove(random.nextInt(MAX_X), random.nextInt(MAX_Y));
Thread.sleep(FIVE_SECONDS);
}
}
}