Skip to content

Instantly share code, notes, and snippets.

@miluna
Last active October 27, 2022 07:48
Show Gist options
  • Save miluna/33983b40ec85bc9d0cb481cceb94d1a6 to your computer and use it in GitHub Desktop.
Save miluna/33983b40ec85bc9d0cb481cceb94d1a6 to your computer and use it in GitHub Desktop.
Gist to prevent computer lockup
import java.awt.*;
public class UnlockScreenApplication {
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
while (true) {
robot.delay(40000);
Point currentLocation = MouseInfo.getPointerInfo().getLocation();
int randomX = getRandomIntBetweenMinusOneAndOne();
int randomY = getRandomIntBetweenMinusOneAndOne();
robot.mouseMove(currentLocation.x + randomX, currentLocation.y + randomY);
}
}
private static int getRandomIntBetweenMinusOneAndOne() {
return (int) (Math.random() - Math.random());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment