The “auto-execute” section

When a script starts…

If you know other programming languages, you might have noticed in your first script, that AutoHotkey doesn’t have some special Main() or __init__() function that is used as starting point for the script. When an AutoHotkey script launches, it just starts execution from the first line of your script. It continues from there line by line until it hits an end point. This is called the auto-execute section.

End points

An end point is marked by a return statement. An example:

1 MsgBox This is line 1. Execution starts here.
2 MsgBox This is line 2. Execution continues here.
3 MsgBox This is line 3. Execution will stop at the "return" in line 4.
4 return
6 MsgBox This is line 6. This will never be executed.


There are some exceptions to this rule: