Start Stop Loop with Same Key

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Dork
Posts: 1
Joined: 06 Jul 2022, 21:29

Start Stop Loop with Same Key

Post by Dork » 06 Jul 2022, 21:32

Hello. I'm sure this has been asked many times but I can't seem to find an answer that helps me, I am new. I'd like to use F9 to Start and Stop my loop. Its a simple loop, and looks like this:

Code: Select all

F9::
loop {
Send, {w down}
Sleep, 1000
Send, {w up}
Send, {s down}
Sleep, 1000
Send, {s up}
}
return
[Mod edit: [code][/code] tags added.]

Thanks!

User avatar
boiler
Posts: 17068
Joined: 21 Dec 2014, 02:44

Re: Start Stop Loop with Same Key

Post by boiler » 06 Jul 2022, 21:45

Code: Select all

#MaxThreadsPerHotkey 2

F9::
	Toggle := !Toggle
	while Toggle {
		Send, {w down}
		Sleep, 1000
		Send, {w up}
		Send, {s down}
		Sleep, 1000
		Send, {s up}
	}
return

Post Reply

Return to “Ask for Help (v1)”