Skip to content

Instantly share code, notes, and snippets.

@saurabhnemade
Last active November 12, 2025 17:54
Show Gist options
  • Select an option

  • Save saurabhnemade/e9730871db858087a78c0e42649a2a66 to your computer and use it in GitHub Desktop.

Select an option

Save saurabhnemade/e9730871db858087a78c0e42649a2a66 to your computer and use it in GitHub Desktop.
Mouse Mover in python
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv

πŸ–±οΈ Mouse Mover – Prevent Screen Lock

A simple Python utility that moves your mouse slightly every few seconds to keep your computer awake and prevent screen lock or sleep mode.


πŸš€ Features

  • βœ… Keeps your system awake automatically
  • βœ… Works on Windows, macOS, and Linux
  • βœ… Lightweight and non-intrusive
  • βœ… Safe to stop anytime with Ctrl + C

🧩 Requirements

Make sure you have Python 3.7+ installed.

Run:

uv sync
uv run main.py
import pyautogui
import time
def prevent_lock(interval=5, move_distance=10):
print("πŸ–±οΈ Mouse mover started. Press Ctrl+C to stop.")
while True:
x, y = pyautogui.position()
pyautogui.moveTo(x + move_distance, y + move_distance)
time.sleep(0.5)
pyautogui.moveTo(x, y)
time.sleep(interval)
if __name__ == "__main__":
try:
prevent_lock()
except KeyboardInterrupt:
print("\nπŸ›‘ Stopped.")
[project]
name = "mouse-mover"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"pyautogui>=0.9.54",
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment