Last active
October 27, 2022 07:48
-
-
Save miluna/33983b40ec85bc9d0cb481cceb94d1a6 to your computer and use it in GitHub Desktop.
Gist to prevent computer lockup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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