Browse Source

rat-race: catch C-c

master
Maxim Likhachev 4 years ago
parent
commit
b15a6f26f1
  1. 14
      scripts/rat-race

14
scripts/rat-race

@ -30,12 +30,16 @@ print(f"[{timestamp()}] Rat-race scenario is started.")
print(f"[{timestamp()}] The mouse cursor will move every {t} seconds.") print(f"[{timestamp()}] The mouse cursor will move every {t} seconds.")
print(f"[{timestamp()}] Current screen resolution is {screenWidth}x{screenHeight}.") print(f"[{timestamp()}] Current screen resolution is {screenWidth}x{screenHeight}.")
while True: try:
x, y = random.randrange(screenWidth), random.randrange(screenHeight) while True:
x, y = random.randrange(screenWidth), random.randrange(screenHeight)
print(f"[{timestamp()}] > moving the cursor to point {x : >4},{y}") print(f"[{timestamp()}] > moving the cursor to point {x : >4},{y}")
pyautogui.moveTo(x, y) pyautogui.moveTo(x, y)
time.sleep(t) time.sleep(t)
except KeyboardInterrupt:
print(f"[{timestamp()}] Interrupted. Exit.")
sys.exit(0)

Loading…
Cancel
Save