Displays an error and quits if a version requirement is not met.

#Requires Requirement



If this does not begin with the word "AutoHotkey", an error message is shown and the program exits. This encourages clarity and reserves the directive for future uses. Other forks of AutoHotkey may support other names.

Otherwise, the word "AutoHotkey" should be followed by any combination of the following, separated by spaces or tabs:

Error Message

The message shown depends on the version of AutoHotkey interpreting the directive.

For v2, the path, version and build of AutoHotkey are always shown in the error message.

If the script is launched with a version of AutoHotkey that does not support this directive, the error message is something like the following:

Line Text: #Requires %Requirement%
Error: This line does not contain a recognized action.


If the script uses syntax or functions which are unavailable in earlier versions, using this directive ensures that the error message shows the unmet requirement, rather than indicating an arbitrary syntax error. This cannot be done with something like if (A_AhkVersion <= "1.1.33") because a syntax error elsewhere in the script would prevent it from executing.

When sharing a script or posting code online, using this directive allows anyone who finds the code to readily identify which version of AutoHotkey it was intended for.

Other programs or scripts can check for this directive for various purposes. For example, the launcher installed with AutoHotkey v2 uses it to determine which AutoHotkey executable to launch, while a script editor or related tools might use it to determine how to interpret or highlight the script file.

Version strings are compared as a series of dot-delimited components, optionally followed by a hyphen and pre-release identifier(s).

A trailing "+" is sufficient to indicate to the reader that later versions are acceptable, but is not required.

Like other directives, #Requires cannot be executed conditionally.

#ErrorStdOut, VerCompare


Causes the script to run only on v2.0, including alpha releases.

#Requires AutoHotkey v2.0-a
MsgBox "This script will run only on v2.0, including alpha releases."

Causes the script to run only on v2.0, including pre-release versions.

#Requires AutoHotkey >=2.0- <2.1

Causes the script to run only with a 64-bit interpreter (EXE).

#Requires AutoHotkey 64-bit

Causes the script to run only with a 64-bit interpreter (EXE) version 2.0-rc.2 or later.

#Requires AutoHotkey v2.0-rc.2 64-bit