AutoHotkey v2 is the current release line, and it is the version worth learning if you are starting today. The rewrite removed most of the guesswork in the old syntax: text is quoted, variables are not, and every command call follows the same shape as a function call.
| Topic | v1.1 | v2 |
|---|---|---|
| Assignment | x = text or x := "text" | Always x := "text" |
| Calling | MsgBox, Hello | MsgBox "Hello" |
| Concatenation | Percent signs around variables | Values written next to each other |
| Blocks | Labels with return | Braces after the hotkey |
| Errors | Often silent | Thrown, so problems surface early |
#Requires AutoHotkey v2.0
count := 0
^!c::
{
global count
count += 1
MsgBox "Pressed " count " time(s)"
}
The #Requires line is worth keeping at the top of everything you write. It stops a v2 script from being launched by a v1 interpreter and producing confusing errors.
tools := ["editor", "terminal", "browser"]
paths := Map("home", "C:\Users", "temp", "C:\Temp")
for item in tools
MsgBox item
MsgBox paths["temp"]
Arrays hold an ordered list and start at index 1; maps hold named entries. Both are read with square brackets.
There is no switch that makes a v1 script run under v2. Work through it line by line: quote the literal text, replace comma-style calls, wrap multi-line hotkeys in braces, and re-check any function whose parameters were reordered. Short scripts usually take minutes; long ones are often faster to rewrite around the same idea.
Read the v2 reference for the formal definitions, work through the tutorials for guided practice, then browse examples and scripts to see the language used at full size. The commands and functions pages explain how the built-in library is grouped.
The current release line of the language, with a consistent expression syntax, quoted strings, brace-delimited hotkey blocks and errors that are thrown instead of ignored.
Not directly. The syntax changed, so a v1 script has to be converted before it will run under v2.
Yes. New material, new libraries and this site's examples all target v2.