Randomised mouse-&-keyboard “keep alive” script for macOS, Windows and Linux.
- ✅ Human-like curved cursor paths
- ✅ Truly random delays (exponential distribution)
- ✅ Optional clicks, scrolls, and “fake” typing noise
- ✅ Sleep-proof on macOS via
caffeinate(Windows / Linux equivalents documented) - ✅ CSV logging for later analysis
- ✅ Zero external services – pure Python, open source
⚠️ Ethics & Risk This project is for educational purposes only. Using it to bypass a platform’s idle or activity rules can violate their Terms of Service. You are solely responsible for how you use it.
[caffeinate] running in the background to block sleep
Keep-awake (sleep-proof) started – press Ctrl-C to quit
[2025-06-29T23:42:11] move (652,533)
[2025-06-29T23:42:11] click (652,533)
[2025-06-29T23:44:21] move (1131,274)
[2025-06-29T23:46:07] scroll
...
| Category | Details |
|---|---|
| Natural movement | Cubic-Bézier paths with 20–60 sub-segments, tiny timing jitter (5–15 ms). |
| Random timing | Action gaps follow an exponential curve – no mechanical “every 60 s” pattern. |
| Mixed events | Low-probability clicks, scrolls, keystrokes (typed + auto-backspaced). |
| Sleep blocker | Launches caffeinate -dimsu on macOS; Windows/Linux one-liners provided. |
| Failsafe | Ctrl-C cleanly stops the script and releases the sleep inhibitor. |
| Logging | Optional log.csv → timestamp, event type, X, Y – easy to load in Pandas. |
git clone https://github.com/yourname/stealth-keep-awake.git
cd stealth-keep-awakepython -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activatepip install -r requirements.txtrequirements.txt
pyautogui==0.9.54
pyobjc==10.1 ; platform_system == "Darwin"
On macOS the first time you run the script, grant Accessibility permission when prompted.
python keep_awake.pyYou’ll see live log lines. Press Ctrl + C to stop.
Open keep_awake.py and adjust the constants at the top:
| Constant | Purpose | Default |
|---|---|---|
WAIT_MEAN_SECONDS |
Average pause between actions | 120 |
MAX_WAIT_SECONDS |
Hard cap to beat display-off timers | 240 |
CLICK_PROB |
Chance a move ends with a click | 0.20 |
TYPE_PROB |
Chance to type / erase random text | 0.07 |
SCROLL_PROB |
Chance to scroll after a move | 0.06 |
EDGE_MARGIN |
How far to stay away from screen edge | 120 |
CSV_LOG |
File name to log events (“” disables) | "" |
All randomness is generated per-action, so two runs never look the same.
- Wait – sleeps a random expovariate delay, capped below the OS sleep limit.
- Move – picks a safe random point and glides there along a Bézier curve.
- Noise – with small probabilities performs a click, scroll, or fake typing.
- Loop – repeats indefinitely while the script is running.
- Sleep guard – on macOS,
caffeinatekeeps the display and system awake.
| OS | Sleep-prevention tip |
|---|---|
| macOS | Built-in: caffeinate -dimsu (already started by the script). |
| Windows | Add before the main loop: import ctypesctypes.windll.kernel32.SetThreadExecutionState(0x80000002) |
| Linux / systemd | Run under: systemd-inhibit --why="stealth-keep-awake" python keep_awake.py |
Pull requests and ideas welcome! Please open an issue first if you’d like to add a major feature.
# run linter & basic checks
pip install ruff pytest
ruff check .
pytestMIT © 2025 Your Name See LICENSE for details.
This repository is provided as is. The maintainers are not responsible for any policy violations, bans, or other consequences that may arise from its use.