Infinite Loop in AutoIt

This autoit tutorial shows how to create an infinite loop, and how to make an exit function.

Edited: 2017-03-18 04:45

Creating an infinite loop in AutoIt is quite easy, you will simply have to leave out the counter of the loop. The easiest way to create a loop that never stops, and just continues running, is likely to use the While loop, we will be looking into that in this Tutorial.

An infinite loop can be made with the while keyword, like demonstrated in the below example.

While 1
; do stuff here
WEnd

Creating an Exit function

Normally you want a way to stop the script, without having to kill it from task manager, such as exiting when hitting a hotkey. To do this we simply create a custom function, and make it possible to call it using the CTRL+ALT+x key combination. I.e.