Created
May 21, 2025 18:40
-
-
Save AldeRoberge/bf299adbe26b3cb96f8a012948e74f8c to your computer and use it in GitHub Desktop.
A AHK script to move the mouse continuously to the right. Will stop when end of screen reached. Shift + L to start or restart. Shift + ESC to quit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
CoordMode "Mouse", "Screen" | |
; Settings | |
moveSpeed := 5 ; Time in ms between movements | |
stepSize := 2 ; Pixels per step | |
; Global state | |
moving := true | |
hasReachedEnd := false | |
; Shift+L toggles pause/start/reset | |
+l::ToggleOrResetMovement() | |
; Shift+Escape quits script | |
+Esc::ExitApp() | |
ToggleOrResetMovement() | |
{ | |
global moving, hasReachedEnd, moveSpeed | |
if (moving) | |
{ | |
; Pause movement | |
moving := false | |
SetTimer MoveMouse, 0 | |
ToolTip "Mouse movement paused", 10, 10 | |
} | |
else | |
{ | |
; Reset and start movement from beginning | |
hasReachedEnd := false | |
MouseMove 0, A_ScreenHeight / 2, 0 | |
moving := true | |
SetTimer MoveMouse, moveSpeed | |
ToolTip "Mouse movement restarted", 10, 10 | |
} | |
SetTimer () => ToolTip(), -2000 | |
} | |
MoveMouse() | |
{ | |
global stepSize, moving, hasReachedEnd | |
if (!moving || hasReachedEnd) | |
return | |
MouseGetPos &x, &y | |
x += stepSize | |
if (x >= A_ScreenWidth) | |
{ | |
x := A_ScreenWidth | |
hasReachedEnd := true | |
moving := false | |
SetTimer MoveMouse, 0 | |
ToolTip "Mouse reached end and stopped", 10, 10 | |
SetTimer () => ToolTip(), -2000 | |
return | |
} | |
MouseMove x, y, 0 | |
} | |
; Start timer initially | |
SetTimer MoveMouse, moveSpeed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment