Skip to content

Instantly share code, notes, and snippets.

View salah3x's full-sized avatar
:octocat:

Salah E. Loukili salah3x

:octocat:
View GitHub Profile
@salah3x
salah3x / NoSleep.java
Created May 17, 2023 21:50
Prevent monitors from going to sleep by regularly moving the mouse
import java.awt.*;
import java.awt.event.InputEvent;
public class NoSleep {
public static void main(String[] arg) throws Exception {
Robot robot = new Robot();
while (true) {
Point point = MouseInfo.getPointerInfo().getLocation();
robot.mouseMove((int) point.getX() + 200, (int) point.getY());
Thread.sleep(2_000);
@salah3x
salah3x / nosleep.py
Last active October 18, 2021 16:58
Prevent monitors from going to sleep by regularly moving the mouse
# Run `pip install mouse` first
from mouse import move, get_position
from time import sleep
# This will move the mouse in squares.
# You can change the size of the square (default 200px) and the
# movement duration (default 2s), the programm will sleep for 20s.
# You can change the square implementation or introduce some randomness
# to the above values to make it difficult to be detected.