How to endless loop

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TNSxPAPA
Posts: 1
Joined: 18 May 2019, 09:54

How to endless loop

18 May 2019, 09:59

So, i am brand new to scripting, and AHK. I have done a large amount of reading but im still learning and this is my first attempt.

What I want to accomplish is;
click, jump down set distance, click, jump up.
Then, after the jump up to where action 1 took place, I want it to just repeat these steps indefinitely untill I stop the input,
I did this by making about 1000 Else if... but, I want it to be neat and efficient.


LCtrl::
Gosub , Use
return

Esc::
Action := 0
Jump := 0
return

Use:
If (Action = 0) {
Click Left
Action++
}
Else If (Action = 1) {
Mousemove , 0 , 36 , 0 , R
Action++
}
Else If (Action = 2) {
Click Left
Action++
}
Else If (Action = 3) {
Mousemove , 0 , -36 , 0 , R
Action++
}
Else If (Action = 4) {
Lcrtl:: Esc
} Loop

return
User avatar
Cuadrix
Posts: 236
Joined: 07 May 2017, 08:26

Re: How to endless loop

18 May 2019, 17:33

What you are looking for are loops; Loop or While-loop
Not sure if this is what you wanted to accomplish, but here is a code from my understanding of your goal;

Code: Select all

#MaxThreadsPerHotkey, 2
Toggle := 0 ; Initially off

; LCtrl to begin loop. Press again to stop, and so on.
LCtrl::
	Toggle := !Toggle
	While (Toggle){
		Click Left
		Mousemove , 0 , 36 , 0 , R
		Click Left
		Mousemove , 0 , -36 , 0 , R
	}
Return

; Esc to stop the input
Esc::
	Toggle := 0
Return
Also, please use the code tags when posting code.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mstrauss2021, Spawnova, zephyrus2706 and 352 guests