This Python script prevents your Windows system from going to sleep while it's running. It's useful when you want to keep your computer awake during long tasks or other activities that don't involve user input.
- Prevents system sleep while the script is active
- Hides the command prompt window by default, but can be shown with the
-v
flag - Includes a system tray icon to exit the program
- Python 3.6 or higher
pystray
librarypygetwindow
library
-
Install Python 3.6 or higher from the official website: https://www.python.org/downloads/
-
Clone this repository or download the
prevent_sleep.py
script and theicon.png
image. -
Install the required libraries:
-
Install Python 3.6 or higher from the official website: https://www.python.org/downloads/
-
Clone this repository or download the
prevent_sleep.py
script and theicon.png
image. -
Install the required libraries:
pip install pystray pygetwindow pip install pyautogui
-
Make installer
pyinstaller --onefile --windowed prevent_sleep.py
Run the script using Python:
python prevent_sleep.py
For mouse movement simulation instead of simulating video player use -m:
python prevent_sleep.py -m
A system tray icon will appear while the script is running. To exit the program and restore the original sleep settings, right-click on the system tray icon and select "Exit".