A simple Python application that automatically moves your mouse cursor to prevent screen timeout and keep your system active.
- Configurable movement interval (default: 60 seconds)
- Configurable movement range (default: ±5 pixels)
- Multi-screen awareness - keeps mouse movements within the current monitor
- Graceful shutdown with Ctrl+C
- Optional failsafe: move mouse to top-left corner to stop (disabled by default)
- Minimal CPU usage
- Cross-platform compatibility (macOS, Windows, Linux)
- Automated setup scripts for all platforms
- Virtual environment isolation
- Python 3.6 or higher
- pip (usually included with Python)
- Windows: Download Python - ensure "Add Python to PATH" is checked during installation
- macOS: Python 3 usually comes pre-installed, or install via Homebrew:
brew install python3 - Linux: Install via package manager:
sudo apt install python3 python3-pip(Ubuntu/Debian) orsudo yum install python3 python3-pip(RHEL/CentOS)
- Clone or download this repository
- Open Terminal in the mouse-mover directory
- Run the setup script:
./run_mouse_mover.sh
- Clone or download this repository
- Double-click
setup_windows.batfor automated setup, OR - Open Command Prompt/PowerShell in the mouse-mover directory and run:
- Command Prompt:
run_mouse_mover.bat - PowerShell:
.\run_mouse_mover.ps1
- Command Prompt:
To run Mouse Mover from anywhere on your system, create a symlink:
# Create ~/.local/bin if it doesn't exist
mkdir -p ~/.local/bin
# Create symlink (choose your preferred name)
ln -sf /full/path/to/mouse-mover/run_mouse_mover.sh ~/.local/bin/msmvr
# Ensure ~/.local/bin is in your PATH (add to ~/.bashrc or ~/.zshrc if needed)
export PATH="$HOME/.local/bin:$PATH"Now you can run msmvr from any directory.
Alternative locations for the symlink:
/usr/local/bin/msmvr(requires sudo, system-wide)~/bin/msmvr(if ~/bin is in your PATH)
Option 1: Automated Setup (Recommended)
- Run
setup_windows.batas Administrator - Choose "y" when prompted to add to PATH
- Restart Command Prompt
- Run
msmvrfrom anywhere
Option 2: Manual PATH Configuration
- Run
setup_windows.bat(createsmsmvr.bat) - Add the mouse-mover directory to your PATH:
- Open System Properties → Environment Variables
- Edit the PATH variable
- Add the full path to your mouse-mover directory
- Restart Command Prompt
- Run
msmvrfrom anywhere
Once installed, you can run Mouse Mover using:
- Global command (if set up):
msmvr - From project directory:
- macOS/Linux:
./run_mouse_mover.sh - Windows:
run_mouse_mover.bator.\run_mouse_mover.ps1
- macOS/Linux:
- Direct Python execution (with manual venv activation):
# Default settings python mouse_mover.py # Custom interval (30 seconds) python mouse_mover.py --interval 30 # Custom movement range (±10 pixels) python mouse_mover.py --range 10 # Enable failsafe feature python mouse_mover.py --failsafe # Both custom settings with failsafe python mouse_mover.py --interval 45 --range 3 --failsafe
-i, --interval: Time in seconds between mouse movements (default: 60)-r, --range: Maximum pixels to move in any direction (default: 5)-f, --failsafe: Enable failsafe (move mouse to top-left corner to stop)-h, --help: Show help message
- Press
Ctrl+Cin the terminal, OR - Move your mouse to the top-left corner of the screen (only if failsafe is enabled with
-f)
mouse-mover/
├── mouse_mover.py # Main Python application
├── requirements.txt # Python dependencies
├── run_mouse_mover.sh # macOS/Linux runner script
├── run_mouse_mover.bat # Windows Command Prompt runner
├── run_mouse_mover.ps1 # Windows PowerShell runner
├── setup_windows.bat # Windows setup/installer
├── README.md # Project documentation
├── CHANGELOG.md # Version history and changes
├── .gitignore # Git ignore rules
└── venv/ # Virtual environment (auto-created)
The runner scripts automatically:
- Check for Python 3 installation
- Create a virtual environment if it doesn't exist
- Install required dependencies (pyautogui, screeninfo)
- Run the mouse mover application
The application detects all connected monitors and constrains mouse movements to the monitor where the cursor is currently located. This prevents the mouse from jumping to other screens and interrupting your workflow.
All scripts use absolute paths, so they work correctly even when called via symlinks or from different directories.
Virtual Environment Issues
- Delete the
venvfolder and run the script again - Ensure you have write permissions in the directory
Mouse Doesn't Move
- Check if security software is blocking pyautogui
- Try running with elevated permissions (sudo/Administrator)
- Ensure no other mouse automation software is running
Multi-Monitor Issues
- Mouse movements are constrained to the current monitor automatically
- If monitor detection fails, check that
screeninfois properly installed - Fallback behavior uses primary monitor or full screen bounds
"Python is not recognized"
- Ensure Python is installed with "Add to PATH" option
- Restart Command Prompt after Python installation
- Try
pythoninstead ofpython3
PowerShell Execution Policy Error
# Run as Administrator:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserOr bypass for single execution:
powershell -ExecutionPolicy Bypass -File run_mouse_mover.ps1"Permission denied" Error
chmod +x run_mouse_mover.shAccessibility Permissions
- Go to System Preferences → Security & Privacy → Privacy → Accessibility
- Add Terminal (or your terminal app) to the allowed list
Missing Python tkinter (required by pyautogui)
# Ubuntu/Debian:
sudo apt-get install python3-tk
# RHEL/CentOS/Fedora:
sudo yum install python3-tkinterX11 Display Issues (for headless/SSH sessions)
- Mouse automation requires a display server
- Won't work over SSH without X11 forwarding
- Optional failsafe: Moving the mouse to the top-left corner stops the application (disabled by default, enable with
-f) - Boundary checking: Mouse movements are constrained within screen boundaries
- Graceful shutdown: Handles interrupt signals properly
- Error handling: Continues running even if individual mouse movements fail
- Preventing screen savers during presentations
- Keeping remote desktop sessions active
- Maintaining VPN connections that timeout on inactivity
- Preventing automatic logout from web applications
- Keeping development environments active during long builds
- Remove virtual environment:
rm -rf venv(orrmdir /s venvon Windows) - Remove symlink/PATH entry (if created):
- macOS/Linux:
rm ~/.local/bin/msmvr - Windows: Remove from PATH via Environment Variables
- macOS/Linux:
- Delete the mouse-mover directory
pyautogui==0.9.54- Mouse and keyboard automationscreeninfo==0.8.1- Multi-monitor detection and bounds
This tool moves your mouse cursor automatically. Only use it on trusted systems and be aware that it will keep your system active, potentially preventing automatic locks or sleep modes.
This project is provided as-is for personal use.
Feel free to submit issues or pull requests for improvements