Reputation: 34627
I have a main file
AutoHotkey.ahk:
#Include Script.ahk
Loop, 3
{
Sleep, 1000
MsgBox, Iteration number is %A_Index%. ; A_Index will be 1, 2, then 3
}
and a Script.ahk:
a::b
The loop in my main file (AutoHotkey.ahk) does not work. However the code in the Script.ahk (a::b
) works.
If I #include
the file after the loop
, both work.
What's wrong with #include
ing the file before the loop
that's making it not work?
Upvotes: 1
Views: 253
Reputation: 1450
Thats because without the #include
the loop is in the autohotkey.ahk scripts auto-execute section and the auto-execute section stops when there is a return, a hotkey or a hotstring maybe more things but atleast those stop the auto-executing of the script and puts the script in to an idle state so you remap is stopping the script from ever getting to the loop.
So when you put the include after the loop the auto-execute section is first stopped after the loop.
If you use a hotkey to start the loop you will be able to start it where ever it is in the script
Upvotes: 4