Created
December 3, 2019 13:35
-
-
Save wbhinton/79c184ae72484c99b462516d18d484ba to your computer and use it in GitHub Desktop.
Python Script to keep your screen alive
This file contains hidden or 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 pyautogui | |
import time | |
import sys | |
from datetime import datetime | |
pyautogui.FAILSAFE = False | |
numMin = None | |
print('We will keep you computer awake by moving the mouse every 3 minutes. ¯\_(ツ)_/¯') | |
if ((len(sys.argv)<2) or sys.argv[1].isalpha() or int(sys.argv[1])<1): | |
numMin = 3 | |
else: | |
numMin = int(sys.argv[1]) | |
while(True): | |
x=0 | |
while(x<numMin): | |
time.sleep(60) | |
x+=1 | |
for i in range(2): | |
pyautogui.moveRel(1, 0, duration=0.1) | |
pyautogui.moveRel(-1, 0, duration=0.1) | |
for i in range(0,2): | |
pyautogui.press("shift") | |
print("Movement made at {}".format(datetime.now().time())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found a different solution:
You only need to press a key every x seconds :) Moving the mouse will be anoying when watching a movie.