2 changed files with 42 additions and 0 deletions
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
# |
||||
# This simple scenario moves the mouse cursor every N seconds, |
||||
# keeping the input devices active and preventing the computer |
||||
# from going into sleep/standby mode. |
||||
# |
||||
# Requirements: |
||||
# |
||||
# python: |
||||
# - pyautogui |
||||
# |
||||
# MacOS: |
||||
# - add iTerm to Settings -> Security & Privacy -> Accessibility. |
||||
# |
||||
|
||||
import pyautogui |
||||
import random |
||||
import time |
||||
import sys |
||||
|
||||
def timestamp(): |
||||
return time.strftime("%Y-%H-%M %T", time.localtime(int(time.time()))) |
||||
|
||||
t = 1 if len(sys.argv) == 1 else int(sys.argv[1]) |
||||
|
||||
screenWidth, screenHeight = pyautogui.size() |
||||
|
||||
print(f"[{timestamp()}] Rat-race scenario is started.") |
||||
print(f"[{timestamp()}] The mouse cursor will move every {t} seconds.") |
||||
print(f"[{timestamp()}] Current screen resolution is {screenWidth}x{screenHeight}.") |
||||
|
||||
while True: |
||||
x, y = random.randrange(screenWidth), random.randrange(screenHeight) |
||||
|
||||
print(f"[{timestamp()}] > moving the cursor to point {x : >4},{y}") |
||||
|
||||
pyautogui.moveTo(x, y) |
||||
|
||||
time.sleep(t) |
||||
|
Loading…
Reference in new issue