diff --git a/scripts/rat-race b/scripts/rat-race index 913bcd0..1d8ada4 100755 --- a/scripts/rat-race +++ b/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()}] Current screen resolution is {screenWidth}x{screenHeight}.") -while True: - x, y = random.randrange(screenWidth), random.randrange(screenHeight) +try: + 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)