Code: Select all
origin := []
MoveMouse(xy) {
MouseMove, xy[1], xy[2], 5.0
}
SetOrigin(pos:=false) {
global origin
if (pos)
origin := pos
else if (origin.Length() == 0) {
MouseGetPos, x, y
origin := [x, y]
}
}
ReturnToOrigin() {
global origin
if (origin.Length() == 0)
return
MoveMouse(origin)
SetOrigin([])
}
Wait(min, max) {
Random, delay, min, max
Sleep, delay
}
Space::
ReturnToOrigin()
Exit
F1::
SetOrigin()
MoveMouse([100, 100])
Wait(1000, 3000)
MoveMouse([500, 500])
Wait(500, 1500)
ReturnToOrigin()
Exit
F2::
SetOrigin()
MoveMouse([1000, 1000])
Wait(1000, 3000)
MoveMouse([1500, 500])
Wait(500, 1500)
ReturnToOrigin()
Exit
I initially had Returns instead of Exits and thought the Exits would fix it they didn't. If I press Space, the mouse returns to origin, but then F1/F2 continues executing, and the same issue happens when I press F1 first and then F2. How do I properly cancel hotkey actions?