AutoHotkey v2 alpha (UPDATES)

Discuss the future of the AutoHotkey language
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

28 Mar 2015, 21:19

AutoHotkey v2 (downloads and information)


Changed "NaN" string back to "".
Added validation for numeric (formerly "can be an expression") command parameters.
Fixed DllCall to throw an exception if the function isn't found.

Merged v1.1.21. Compared to previous v2 alphas, the changes are:
  • Remove (different from v1) was renamed to Delete.
  • Length now returns 0 if only negative keys exist.
  • MaxIndex and MinIndex have been restored.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

02 May 2015, 20:14


Merged v1.1.22.00.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

08 Jun 2015, 03:14


Changed objects to treat pure decimal numeric string keys as integers.
Changed Hotkey command to never treat On/Off/Toggle/AltTab as a label.

Fixed var return optimization (crashing etc., only seemed to affect AutoHotkeySC.bin).

Merged v1.1.22.02.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

13 Jun 2015, 01:05


Fixed use of commas between parentheses with If (expression).
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

24 Oct 2015, 21:58


Fixed x[y*] := z.
Fixed instance var sub-initializers (x.y := z in class body, where x was previously declared).
Merged v1.1.22.07.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

09 Nov 2015, 17:05


Fixed returning of a built-in var without other operators, such as return A_AhkVersion.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

25 Dec 2015, 20:35


Fixed Object._NewEnum() creating two enumerators and leaking one (thanks HotKeyIt).
Fixed vars to trigger __Delete after clearing their object, not before.
Fixed local vars to not retain values when __Delete causes recursion (thanks HotKeyIt).


Merged v1.1.22.09.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

05 Feb 2016, 19:06


Fixed appending small values to numeric vars.
Merged v1.1.23.01.
Made A_CoordMode.., A_..Delay/Duration.., A_Send.. and A_StoreCapslockMode vars writable.
Added RegDeleteKey, RootKey\SubKey.
Changed RegDelete to delete the key's default value when ValueName is omitted/empty, for consistency with RegWrite, RegRead and A_LoopRegName.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

11 Mar 2016, 22:04


Merged v1.1.23.03.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

03 Jun 2016, 23:04


Changed StrGet to truncate the string at the first binary zero (null terminator), as in v1. Specifying a negative Length now causes it to extract exactly Abs(Length) characters (as previous builds did for positive values), utilizing v2's support for binary zero in strings.

Fixed omitting of output vars with function syntax. MouseGetPos(, y) now works. MouseGetPos("", y) is now invalid.
Fixed detection of simple expressions erroneously used as output vars (to show an error message instead of crashing).
Optimized WinGet.
Some other code maintenance.

Merged v1.1.24.00.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

15 Oct 2016, 02:02


Input now returns EndKey:a-z in lower-case if that's what the keyboard layout returns.

Added the capability to set the default dialog title (for MsgBox, InputBox, FileSelect, DirSelect and Gui) by assigning to A_ScriptName.

The following names are no longer allowed as variable, function, class or window group names: If, Else, Loop, LoopFile, LoopRead, LoopReg, LoopParse, For, While, Until, Break, Continue, Goto, Gosub, Return, Try, Catch, Finally and Throw. The primary purpose of this is to detect errors such as if (ex) break.

Experimental: Loop, LoopFiles, LoopRead, LoopReg and LoopParse now support a function-like syntax, where the entire parameter list is enclosed in parentheses and all parameters are expressions. OTB is also supported. For example:

Code: Select all

LoopRead(A_ScriptFullPath) {
    MsgBox("The first line of this script is: " A_LoopReadLine)
Currently there must not be a space between "Loop" and the sub-command name, due to ambiguity. (Files, Read, Reg and Parse are not reserved names.)

Return and Until no longer require a space or comma after the function name if the expression starts with an open-parenthesis. This brings them in line with If and While.

Bug fixes:
Corrected FileOpen exception message.
Fixed Sort functions with 3 parameters.
Fixed Loop,Files/Parse/Read/Reg .. Until.
Fixed ObjBindMethod, ObjPop and ObjPush to have an OutputVar when called as commands.

Merged v1.1.24.02.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

26 Nov 2016, 01:33


Fixed dynamic calling of built-in command-functions with surplus parameters.
Fixed (via merge) Exit within an OnExit function to act like return false, not return true.
Merged v1.1.24.03.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

19 Mar 2017, 04:24


Fixed expression lines starting with "".prop, as in "".base.x := y.

Merged v1.1.25.01.

Changed syntax of MsgBox, InputBox and TrayTip.

Code: Select all

MsgBox [, Text, Title, Options, OutputVar]
Result := MsgBox([Text, Title, Options, OutputVar])

InputBox, OutputVar [, Text, Title, Options, Default]
Result := InputBox([Text, Title, Options, Default])

TrayTip [, Text, Title, Options]
TrayTip([Text, Title, Options])
See the documentation or v2-changes for details.

  • MsgBox now treats commas the same as every other command. No more "smart" comma handling.
  • A_MsgBoxResult was removed.
See MsgBox, InputBox, TrayTip - AutoHotkey v2 Development for background info.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

10 Jun 2017, 21:57


The Big Changes

Removed legacy command syntax and %expression% substitution in strings.

That is, a "command" is now just a function or method call which sits at the start of the line, lacks parentheses and discards its return value. Aside from parentheses, commands and functions now share the same syntax. In general, functions with a single return value do not use an output variable, so usually require parentheses to be useful. See v2-changes for details.

Related changes:
  • Added goto(expr) and gosub(expr) statements (not functions), since goto and gosub without parentheses do not support variables.
  • Removed load-time validation code for command parameters, which no longer applied due to expressions.
  • Removed LoopFiles/LoopParse/LoopRead/LoopReg (now require a space).
  • Removed MsgBox's redundant OutputVar.
  • Removed Deref().
  • Changed `, to have no special meaning (previously it acted as though enclosed in parentheses; i.e. did not delimit command parameters). This ensures `, has the same effect regardless of whether parentheses are used.
  • Removed the , and % continuation section options and the escaping of , by default, since there's no longer any reason to escape it.
  • Added InputEnd(), since Input no longer has an OutputVar to omit. InputEnd sets ErrorLevel to "End".
  • Added RandomSeed(), since Random no longer has an OutputVar to omit.
Implemented the new GUI API.

Other Syntax Changes

Changed /* to allow */ at the end of the line. See v2-changes for comments.

Enabled the `s escape anywhere `t is allowed. It was previously only allowed by #IfWin and (Join.

Improved load-time syntax validation of expressions.

Removed *deref operator.

Removed Object.Length (not Object.Length()) because it causes surprising behaviour with associative arrays (so does "base", but that will be addressed later). Object.Length was added in v2.0-a049 (c1196f1e).

Fixed sub-expressions like (A_WorkingDir := y) producing an unusable variable reference in some contexts.

Library Changes

Replaced ClipboardAll variable with ClipboardAll() function.
  • Replaced "binary clip" var attribute with a built-in object type.
  • Removed special clipboard modes of FileRead/FileAppend.
  • Added general "RAW" binary mode for FileRead/FileAppend.
  • Changed ClipboardAll to always use 32-bit data sizes.
Split Control, ControlGet, Drive and DriveGet sub-commands into separate functions (with some renaming).

Changed ControlChoose(N) to allow N = 0 (deselect all).

Optimized ControlGetCurrentCol().

Changed ControlGetFocus to set ErrorLevel:=0 when there's no focus.

Fixed ControlGetTab() to return 0 when no tab is selected.

Removed ControlTabLeft/ControlTabRight and added ControlSetTab.
  • TabLeft/TabRight were equivalent to ControlSend with {Left/Right} after SetKeyDelay -1, 0.
  • TabLeft/TabRight did not work correctly with TCS_BUTTONS.
Changed parameter order of ControlMove, ControlSend, ControlSetText, WinSetTitle and WinMove to be consistent with other functions.

Fixed DirExist(pattern) to skip over files matching the pattern.

Changed FileExist and DirExist to ignore . and .. in dir\*.* so they behave as most users would expect (for detection of empty vs. non-empty directories).

Fixed FormatTime to return strings for WDay/YDay (not pure numbers) and throw an exception if Format exceeds 2000 chars (vs. silently failing).

Changed MsgBox and InputBox to allow explicitly empty title.

Changed SoundSet and SoundGet to throw an exception for "Invalid Control Type or Component Type" (invalid parameter).

File I/O

Changed FileRead and FileAppend to be more consistent.

Code: Select all

Data := FileRead([Filename, Options])
FileAppend(Data [, Filename, Options])
; Options: "`n m1024 Encoding|RAW"
; Default to no end-of-line translation.
Changed File.ReadLine() to always recognize `r, `n and `r`n as line endings. EOL options now only affect translation of characters passed from or to the script.

Reverted FileOpen EOL options/default to how they were in v1 (with the exception of ReadLine()), for consistency with FileRead/FileAppend.

Changed File.RawRead/RawWrite to support binary strings and address_var.
  • If a variable containing a pure number is passed, the number is used as an address, consistent with NumPut/NumGet.
  • RawWrite can accept a binary string directly, such as one returned by ClipboardAll().Data.
  • RawRead updates the variable's length to include all of the read data (rounded up to the next multiple of sizeof(TCHAR)).
Bytes (param #2) is optional when passing a binary string/variable:
  • For RawWrite, it defaults to the binary string length.
  • For RawRead, it defaults to the variable's capacity.
Changed A_FileEncoding to return "CP0" instead of "", because otherwise, enc := A_FileEncoding ... FileAppend(s, f, enc) may not have the intended effect.


Merged A_LoopRegSubKey into A_LoopRegKey (and removed the former).

Changed parameters of RegWrite/RegDelete/RegDeleteKey.
  • Put Value first for RegWrite, like IniWrite.
  • If the current Loop Reg item is a subkey, let the Reg functions operate on it by default (omit KeyName but specify ValueName).
  • If the current Loop Reg item is a value, let the Reg functions operate on A_LoopRegKey by default.
  • Let RegWrite specify a new ValueType when writing to the current Loop Reg value.
  • Change RegDelete without params to never delete keys; only values.
  • Let RegDeleteKey's param be omitted to delete the current key.

New documentation has been written for most of the changes, but not all examples have been updated. The syntax shown for each function (in the yellow blocks) has been updated. The new "command" syntax is not fully documented, but neither was the old syntax.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

11 Jun 2017, 17:09


Merged v1.1.26.00.

Fixed FileDelete/SetAttrib/SetTime to use v2 policy for invalid params (throw).
Changed FileSetAttrib without +/-/^ to overwrite attributes.
Changed type names returned by Type(obj).
Improved accuracy of ListLines with the new syntax.
Restored ListLines "On" as the default.
  • ListLines has better debugging value if it can be used without the author having first anticipated that it will be needed.
  • Performance impact is negligible or sometimes not measurable.
Revised SendMessage and PostMessage with variables/strings.
  • All strings are passed by address, whereas previously only quoted strings in command mode were passed by address, and all other values were assumed to be numbers.
  • Variable length is updated if a variable is passed by reference.
  • Variable length is not updated if a variable's address is passed, because that's outside what the language is supposed to allow (and difficult/impossible to achieve with pure expressions).
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

15 Jul 2017, 21:08


Fixed Exception(,-n) to only count user-defined functions/subs as in v1.
Fixed not operator being flagged as an error.
Fixed e+(1) being misinterpreted as a function call.
Added detection of invalid literals such as (.) and (.foo).
Fixed DirExist() without wildcards to return blank if not a directory.
Merged v1.1.26.01.
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

24 Dec 2017, 19:50


Fixed Sort(var) and Sort("quoted`nstring") to not modify the parameter.
Fixed crashes caused by invalid parameterless function calls.
Fixed "low memory" bug in FileRead when file has an odd number of bytes. [PR #82 from HotKeyIt]
Changed GuiControl.Focus() to use WM_NEXTDLGCTL.
  • Fixes default button highlighting.
  • Causes Edit control text to be selected.
Changed Gui.AddUpDown() to suppress Edit.Change events.
Replaced Menu command with MenuCreate, Menu object, TraySetIcon, and the ability to write to A_IconTip, A_IconHidden and A_AllowMainWindow.
Changed A_IconTip to return the default tip if none was set.
Setting A_IconTip := "" disables the tooltip instead of restoring it to the default (which is A_ScriptName if that hasn't been changed).
Removed A_ThisMenuItem and A_ThisMenuItemPos.
Fixed Sort("") to return "". [PR #88 from HelgeffegleH]
Fixed integer key assignment in class body breaking string keys. [Supersedes pull request #87.]
Fixed SetTimer and Hotkey functions' inability to accept an object without a variable reference.
Replaced A_CaretX/Y with CaretGetPos(x, y).
Merged v1.1.27.00 (new documentation not merged).
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


06 Jan 2018, 22:13

Fixed assume-global and assume-static (broken by force-local).
Fixed throw (broken by bad merge in commit fffc60d).
Fixed ClipboardAll().

Changed bitwise-NOT (~) to always treat number as 64-bit.
Changed Loop Parse/Read/Reg/Files comma to be optional (syntax not final).
Changed string->integer conversion to allow overflow consistent with arithmetic operations. For example, these expressions are now true:

Code: Select all

9223372036854775807+1 == 9223372036854775808
0x10000000000000001 ==  1
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


21 Jan 2018, 17:03

Renamed File.__Handle to File.Handle.
Changed Input and hotstrings to treat Shift+BS the same as plain BS.
Fixed standalone ternary expressions like x ? ++y : --z. Specifically, those which start with a word and space followed by '?'.
Fixed possible crashes when reporting syntax errors with and/or/not/etc.
Revised operand and keyword operator parsing to reduce code size.
Changed lines beginning with 0-9 to never be interpreted as function call statements. This allows 0 < 1 ? x : y to work.
Changed Gui.Add to default to y+m/x+m when xp+0/yp+0 is used.
Revised line continuation for keyword operators.
  • is/in/contains are now included (but in/contains are still reserved).
  • These cause continuation even if followed by an operator such as := (since such expressions are invalid either way).
Revised var name validation.
  • Operator keywords are reserved for variables/functions.
  • Control flow keywords are no longer reserved for methods/groups.
  • Smaller code.
Removed obsolete same-line action code for IF.
Revised parsing and validation of GUI control option chars.
  • Integer and floating-point are accepted.
  • Invalid numbers or color values are detected as errors.
  • Smaller code.
Added capability to specify an additional offset after X+M/Y+M.
Reduced code size of string->int (32-bit) conversions. Behaviour for out of range values is now more consistent with literal integers/math expressions (bitwise truncation vs. range truncation).
Added WinGetClientPos.
Fixed wrong args being marked as OutputVars in function call statements.
Changed For to throw exceptions if enumeration fails for some reason. [PR #89 from Helgef]
Simplified implementation of function call statements.
Added load-time validation of output vars of built-in functions().
Added error detection of lines which are too long (instead of splitting).
Fixed A_IsCompiled in release builds [broken by c05ab55].
Changed built-in commands to be handled as functions.
  • Fixes inconsistencies:
    • Defining a function with the same name now overrides it, just as it overrides other built-in functions.
    • Output variables can be expressions; e.g. MouseGetPos which? x:y
  • Will require optimization (such as converting all commands to BIFs).
  • Excludes control flow statements.
Revised remapping mechanism to allow other architectural changes and reduce code size.
Removed obsolete validation code.
Removed #MustDeclare and Var keyword.
Removed the exceptions for +=/-=/++/-- interpreting empty as zero.
Merged v1.1.27.07.
Revised detection of l-values in assignments.
  • Applies to validation of assignments and detecting when built-in vars and double-derefs should produce a writable variable.
  • Enclosing l-value in parentheses does not affect the result.
  • Pre-inc/dec are validated better.
Enabled the use of built-in vars as output vars (but not ByRef).
Posts: 7919
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


23 Jan 2018, 17:06

Added natural line continuation via ()/[]/{}. For example:

Code: Select all

   length := mylongparametername1.Length()
myfunction [
   "item 1",
   "item 2",
], 2
for k, v in {
    key1: "value1",
    key2: "value2",
  } {
    MsgBox k "=" v
(Not documented yet.)

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 6 guests