while sleeptime <= 10 and not breakloop
continue
I would suggest not using a loop which just "continues". It will loop as fast as possible, needlessly consuming CPU time.
If you are using a loop, there is no need for a timer.
Code: Select all
while A_Index <= 100 and not breakloop
Sleep 100
or
Code: Select all
loop 100
Sleep 100
until breakloop
You can still set breakloop from a hotkey or any other event, and you can adjust the numbers to check more or less frequently if needed.
There may be some inaccuracy caused by "drift", as each iteration may take longer than 100 ms. If you want more accuracy, you can check the time:
Code: Select all
start := A_TickCount
while (A_TickCount - start) < 10000 and not breakloop
Sleep 100
This may still go as much as 100 ms over 10 seconds.
If you use
Sleep 10000, there is no way to cause it to return early. You can only interrupt it and do something else in the meantime (such as execute another hotkey or timer).