Stop a specific loop Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Stop a specific loop

21 Feb 2018, 12:35

Hello everyone,
I have a script with a loop that launches several subroutines, some with other subroutines with another loops inside, some launching other subroutines without loops.
I tried everything to stop the initial loop from launching them all at once.
I managed to stop the A_Index variable jumbling with a variable translation.
I tried to Use the Looping:= False command but it didn't work with all the loops inside the subroutines needing to run.
I could try a different loop for each subroutine but I guess I would still be with the same problem with different indexes launching the same subroutine instead of all types.
Is there a way to stop a specific loop then reactivate it?
Its all I need :)
Regards.
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Stop a specific loop

21 Feb 2018, 12:48

It can be only 1 type (subroutine) per loop index. I could try breaking the loop After the gosub, and adding the index and calling the loop again at the end of the last subroutine called by the initial subroutine for all types .
stealzy
Posts: 91
Joined: 01 Nov 2015, 13:43

Re: Stop a specific loop  Topic is solved

21 Feb 2018, 13:10

Use SetTimer instead.

Code: Select all

#Persistent
Global Stop_f_loop := false
SetTimer f, -1
Return

F1::Stop_f_loop := true

F2::
Stop_f_loop := false
SetTimer f, -1
Return

f() {
	static i := 0
	MsgBox % ++i
	If Not Stop_f_loop
		SetTimer f, -1
}
Noo0B
Posts: 151
Joined: 26 Jan 2018, 19:54

Re: Stop a specific loop

21 Feb 2018, 14:59

Thanks for the reply!
Although that was not exactly what I wanted I can see that you have great knowledge of AHK. I have no idea what ( ) does for example.
I actually got it fixed by doing the break after calling the sub and the index add at the end of the sub before recalling the loop.
Only problem is that an if statement fails to evaluate a variable at the end of the sub. For example:

Code: Select all

If (Var = W) {
Var2:= 123
Var3:= 456
} Else {
MsgBox %Var%
}
I keep getting the MsgBox with W...
It works well in another script
Isn´t that something?
Thanks and Regards!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: NinjoOnline and 278 guests