AFK Mouse Jiggler
This utility prevents your computer from going to sleep or locking the screen by simulating mouse activity. It periodically moves the mouse cursor slightly, mimicking user presence.
Modules Used:
- pyautogui: To move the mouse cursor.
time: To handle intervals between movements.random: To generate random movement patterns.- argparse: To handle command-line arguments.
Installation
pip install pyautogui
The Code
Save this as jiggler.py.
import pyautogui
import time
import random
import argparse
import sys
def start_jiggler(interval):
print(f"AFK Jiggler started. Interval: {interval} seconds.")
print("Press Ctrl+C to stop.")
print("Move mouse to a corner of the screen to trigger Fail-Safe.")
try:
while True:
# Generate random offset (-5 to 5 pixels)
x_off = random.randint(-5, 5)
y_off = random.randint(-5, 5)
# Move relative
# duration=0.2 makes the movement visible/smooth rather than instant
pyautogui.moveRel(x_off, y_off, duration=0.2)
# Move back to original position (optional, keeps cursor roughly in place)
pyautogui.moveRel(-x_off, -y_off, duration=0.2)
print(f"[{time.strftime('%H:%M:%S')}] Jiggled.")
time.sleep(interval)
except KeyboardInterrupt:
print("\nJiggler stopped by user.")
except pyautogui.FailSafeException:
print("\nFail-Safe triggered from mouse corner. Stopped.")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="AFK Mouse Jiggler")
parser.add_argument("-i", "--interval", type=int, default=60, help="Interval in seconds (default: 60)")
args = parser.parse_args()
start_jiggler(args.interval)
Usage
# Run with default 60s interval
python jiggler.py
# Run with 5 minute interval
python jiggler.py --interval 300