Last active
April 15, 2025 13:31
-
-
Save katzefudder/bbeac78f22e601c18b2d3436e217382b to your computer and use it in GitHub Desktop.
don't let your computer fall asleep by keeping your mouse busy from time to time :)
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 pyautogui | |
import time | |
from datetime import datetime | |
import argparse | |
def main(): | |
parser = argparse.ArgumentParser(description="Prevent standby by moving the mouse.") | |
parser.add_argument("--duration", type=int, default=None, help="Time in seconds until the script stops (optional)") | |
args = parser.parse_args() | |
print(f"Starting at {current_time()}.") | |
start_time = time.time() | |
while args.duration is None or (time.time() - start_time) < args.duration: | |
pyautogui.moveRel(240, 0) # Moves mouse slightly | |
time.sleep(10) # Every 10 sec | |
pyautogui.moveRel(-240, 0) # Moves it back | |
print(f"Exiting gracefully at {current_time()}.") | |
def current_time(): | |
now = datetime.now() | |
return now.strftime("%Y-%m-%d %H:%M:%S") | |
if __name__ == "__main__": | |
try: | |
main() | |
except KeyboardInterrupt: | |
print(f"\nExiting gracefully at {current_time()}.") | |
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 pyautogui | |
import time | |
from datetime import datetime | |
import argparse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment