Last active
October 18, 2021 16:58
-
-
Save salah3x/fbea506d0d65922b9145533050add737 to your computer and use it in GitHub Desktop.
Prevent monitors from going to sleep by regularly moving the mouse
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
# 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. | |
while True: | |
move(get_position()[0] + 200, get_position()[1], duration=2) | |
sleep(20) | |
move(get_position()[0], get_position()[1] + 200, duration=2) | |
sleep(20) | |
move(get_position()[0] - 200, get_position()[1], duration=2) | |
sleep(20) | |
move(get_position()[0], get_position()[1] - 200, duration=2) | |
sleep(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another implementation using the
autopy
library: