Browse Source

rat-race: catch C-c

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

6
scripts/rat-race

@ -30,7 +30,8 @@ print(f"[{timestamp()}] Rat-race scenario is started.") @@ -30,7 +30,8 @@ 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:
try:
while True:
x, y = random.randrange(screenWidth), random.randrange(screenHeight)
print(f"[{timestamp()}] > moving the cursor to point {x : >4},{y}")
@ -38,4 +39,7 @@ while True: @@ -38,4 +39,7 @@ while True:
pyautogui.moveTo(x, y)
time.sleep(t)
except KeyboardInterrupt:
print(f"[{timestamp()}] Interrupted. Exit.")
sys.exit(0)

Loading…
Cancel
Save