AutoHotkey_L Features [home]


Control Flow
Break LoopLabelBreak out of a loop or any number of nested loops.
Continue LoopLabelContinue a loop, even from within any number of nested loops.
For x,y in zLoop through the contents of an object.
Loop UntilLoop until a condition is true. Applicable to any type of Loop.
Commands
FileEncodingSets the default encoding for FileRead, FileReadLine, Loop Read, FileAppend, and FileOpen.
See also: Text Encodings
Menu, IconSets or removes a menu item's icon.
SendInput {U+nnnn}Sends a Unicode character. Unicode characters may be used directly in Unicode builds.
SetFormat, IntegerFast, h|HSet lower-case or upper-case hexadecimal format.
Transform, HTMLPerform code page or HTML transformations.
Directives
#If expressionSimilar to #IfWinActive, but for arbitrary expressions.
#IfTimeoutSets the maximum time that may be spent evaluating a single #If expression.
#MenuMaskKeyChanges which key is used to mask Win or Alt keyup events.
#Include <Lib>Includes a script file from a function library folder.
#WarnEnables or disables warnings for selected conditions that may be indicative of developer errors.
Functions
ComObj... --
ComObjActive
ComObjEnwrap/Unwrap
ComObjParameter
ComObjType

Retrieves a registered COM object.
Wraps/unwraps a COM object.
Wraps a value and type to pass as a parameter.
Retrieves a COM object's type information.
ComObjArrayCreates a SAFEARRAY for use with COM.
ComObjConnectConnects a COM object's event sources to functions with a given prefix.
ComObjCreateCreates a COM object.
ComObjErrorEnables or disables notification of COM errors.
ComObjFlagsRetrieves or changes flags which control a COM wrapper object's behaviour.
ComObjGetReturns a reference to an object provided by a COM component.
ComObjQueryQueries a COM object for an interface or service.
ComObjTypeRetrieves type information from a COM object.
ComObjValueRetrieves the value or pointer stored in a COM wrapper object.
FileOpenProvides object-oriented file I/O.
IsObjectDetermines if a value is an object.
StrPut / StrGetCopies a string to or from a memory address, optional converting it between code pages.
TrimTrims certain characters from the beginning and/or end of a string.
RegEx (?CNumber:Function)Calls a function during evaluation of a regex pattern.
Variadic FunctionsFunctions may accept a variable number of parameters via an array.
Objects
GeneralBehaviour and usage of objects in general.
ObjectAssociative arrays which can be extended with other functionality.
EnumeratorAllows items in a collection to be enumerated.
FileProvides an interface to access a file. FileOpen returns an object of this type.
ComObjectSee ComObj functions above.
Variables
A_IsUnicodeIn Unicode builds, this variable contains 1 (true). In ANSI builds it is not defined, so is effectively false.
A_FileEncodingContains the default encoding for various commands; see FileEncoding.
A_OSVersionContains WIN_7 on Windows 7, else one of the values documented here.
A_PtrSizeContains the size of a pointer, in bytes. This is either 4 (32-bit) or 8 (64-bit).
Datatypes
PtrEquivalent to Int in 32-bit builds and Int64 in 64-bit builds. Supported by DllCall, NumPut and NumGet.
AStr, WStrSupported only by DllCall; see Script Compatibility.
Unicode
CompatibilityHow to deal with Unicode in DllCall, etc.
Script FilesUsing Unicode in script files.
SendInputUsing Unicode with SendInput.
Other
DebuggingInteractive debugging features (line by line execution etc.).
Icon SupportResource identifiers and improved support for various icon sizes.
Gui Text QualityControl text anti-aliasing on a Gui.
Other ChangesChanges affecting script compatibility.
Version HistoryHistory of AutoHotkey_L revisions.

Changes to Commands

Text Encodings

FileRead, FileReadLine, Loop Read and FileAppend support the majority of Windows-supported text encodings, not just the system default ANSI code page. FileEncoding can be used to set the default encoding, which can be overridden for FileRead and FileAppend as follows:

FileRead, OutputVar, *Pnnn Filename
FileAppend [, Text, Filename, Encoding]

While nnn must be a numeric code page identifier, Encoding follows the same format as FileEncoding.

See also: Script Compatibility

Improvements to Icon Support

Unusual Sizes

Icon resources of any size supported by the operating system may be extracted from executable files. When multiple sized icon resources exist within an icon group, the most appropriate size is used. Prior to revision 17, an arbitrary icon resource was selected by the system, scaled to the system large icon size, then scaled back to the requested size.

Resource Identifiers

Negative icon numbers may be used to identify a group icon resource within an executable file. For example, the following sets the tray icon to the default icon used by ahk files:

Menu, Tray, Icon, %A_AhkPath%, -160