-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmover.py
More file actions
34 lines (26 loc) · 877 Bytes
/
mover.py
File metadata and controls
34 lines (26 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pyautogui
import random
import time
pyautogui.FAILSAFE = True # Keep fail-safe on for emergency stop
# Get screen dimensions
screen_width, screen_height = pyautogui.size()
# Define a margin to avoid edges
MARGIN = 10
FIVE_SECONDS = 5
while True:
try:
# Generate random safe coordinates
x = random.randint(MARGIN, screen_width - MARGIN)
y = random.randint(MARGIN, screen_height - MARGIN)
# Move the mouse
pyautogui.moveTo(x, y)
print(f"Cursor moved to: ({x}, {y})")
# Simulate a shift press
pyautogui.press('shift')
print("Shift key pressed.")
except pyautogui.FailSafeException:
print("⚠️ Fail-safe triggered! Mouse likely moved to the corner.")
# Wait a moment before trying again
time.sleep(2)
# Wait before repeating
time.sleep(FIVE_SECONDS)