Using GetKeyState() and loops
问题 I'm trying to write a script that has a loop in which the upper arrow key is pressed every two seconds. The loop must be activated when I press the spacebar and deactivated when I press it again. I'm now using this. $Space:: if GetKeyState("Space", "P") { Loop { Sleep 2000 Send {Up} if GetKeyState("Space", "P") { return } } } For some reason, the if condition inside the loop doesn't work, i.e. I can't get out of the loop. I hope anyone can help me out... 回答1: You wouldn't need the first if