AutoHotkey v2 alpha (UPDATES)

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

AutoHotkey v2 alpha (UPDATES)

13 Feb 2014, 22:42

AutoHotkey v2

For information about AutoHotkey v2, click the link above. A summary of changes will be posted here each time a new alpha is released.

Changes from v1.1 to v2.0-a

v2.0-a045-bbf6f99

New operator is replaces if var is type. Since type is a string, it must be enclosed in quote marks (or a variable) - for example, n is 'number'. The same type names are supported as before, plus object and byref. Additionally x is y, where y is an object, checks if x derives from y, directly or indirectly.

Keywords contains and in are reserved for future use.

See Error Handling in v2-changes. In particular:
  • Wrapping commands in a try block no longer causes them to throw exceptions.
  • DllCall and RegExMatch/Replace always throw exceptions instead of using ErrorLevel.
  • Exceptions are thrown for more failure conditions within expression evaluation and object usage.
  • OnMessage throws on failure and returns an empty string if there was no previous function.

Commands() which returned ErrorLevel in previous v2 alphas now return !ErrorLevel (1 on success and 0 on failure), except for RunWait and SendMessage, which still return ErrorLevel. Commands which set ErrorLevel now do so regardless of how they are called. See Command() in v2-changes for an overview of how this works.

Fixed output vars of built-in functions to not require percent signs when called with command syntax.

All WinSet' functions now return 1 on success, 0 on failure, while ErrorLevel is set to 0 on success, 1 on failure.

word ? x : y, word ++ and word -- are no longer expressions, since word can be a user-defined command. To write a standalone ternary, post-increment or post-decrement expression, either omit the space between the variable and the operator, or wrap the variable or expression in parentheses.

Removed ComObjMissing(). Write two consecutive commas instead: x.y(a, , c) or p := [a, , c], x.y(p*).

Fixed x[1,2]+=y and %i-1%.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

11 Apr 2014, 18:57

v2.0-a046-692ef59

Removed "polymorphic" behaviour of ComObj...().
Split ComObjActive() from ComObject() and changed "ownership" rules - see below.
Removed ComObjUnwrap(obj) and ComObjTypo(obj,...).
Changed regex option `a to enable \R to match Unicode newlines.
Disallow methods with OnMessage to avoid confusion.
Restored the #Persistent directive.
Changed float format string for better accuracy and to avoid truncation.
Fixed commands which don't set ErrorLevel at all to not return 1.
Changed FileOpen() error handling for consistency with other commands.

Renamed Args to A_Args and changed behaviour slightly.
  • If no args, assign an empty array so A_Args[1] doesn't cause an error.
  • Made it super-global so behaviour is like other built-in vars.

Hotkey no longer defaults to the script's bottommost #If/#IfWin. Hotkey/hotstring threads default to the same criterion as the hotkey, so Hotkey, %A_ThisHotkey%, Off turns off the current hotkey even if it is context-sensitive. All other threads default to the last setting used by the auto-execute section, which itself defaults to no criterion (global hotkeys).

ComObject(pdsp), ComObject(9, pdsp) and ComObject(13, pdsp) no longer call AddRef by default; they default to "taking ownership" of the pointer. Most v1 scripts which use ComObjEnwrap(pdsp) (within the first few pages of Google results) used it incorrectly; i.e. they did not release their own copy of the pointer. For v2, the script must call ObjAddRef(pdsp) before ComObject(pdsp) if it does not "own" the reference (i.e. because the pointer will be released automatically, either when the wrapper object is released or immediately as a side-effect of querying for IDispatch within ComObject()). The flags parameter now only affects SafeArrays.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

24 Apr 2014, 22:14

v2.0-a047-3defc4a

Fixed 'co', 'con', 'contain', etc. to not be reserved in expressions.
Merged v1.1.14.04.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

20 Jun 2014, 21:34

v2.0-a048-573f142

Improved Click to support function syntax better - Click(x, y).
Changed RegExMatch/RegExReplace to throw on PCRE execution errors.
Changed &(var:=1) to return var's 64-bit number buffer instead of its string buffer.
Changed objects to treat numeric string keys as strings, not integers.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

28 Jul 2014, 07:53

v2.0-a049-ea663d0

All built-in methods of Objects and SafeArrays no longer support the _ (underscore) prefix, except _NewEnum, which now requires it (for compatibility with COM objects). ObjNewEnum(x) is still equivalent to x._NewEnum() for Objects.

To remove common points of confusion related to the dual nature of Objects (as associative arrays which can be used like linear arrays), the methods Insert and Remove have been split into the following (where Object, Array and Stack are all simply objects):

  • Value := Object.Remove(Key): Remove Key and return its prior value.
  • Count := Object.Remove(FirstKey, LastKey): Remove a range of keys and return the number of actual key-value pairs removed. Unlike v1, does not affect any of the remaining keys.
  • Array.InsertAt(Index, Value1, ...): Insert one or more values at the given position.
  • Value := Array.RemoveAt(Index): Remove and return the array element at Index.
  • Count := Array.RemoveAt(Index, vCount): Remove all array elements from Index to Index+vCount-1. Count (return value) includes only elements which actually existed within the array.
  • Stack.Push(Value1, ...): Insert one or more values at the end of the array.
  • Value := Stack.Pop(): Remove and return the last array element.
  • Built-in functions equivalent to each method also exist; e.g. ObjPop(Stack).
  • ObjRawSet(Object, Key, Value): Assigns a value to the object, bypassing any meta-functions.

Object.MaxIndex() has been changed to Object.Length() (or Object.Length) and now returns 0 if there are no integer keys, to make it easier to use.

Object.MinIndex() has been removed, since it was the rarely used counterpart of MaxIndex. A for-loop can be used to find the lowest key.

Parameter count validation and out-of-memory handling in Object methods has been brought in line with the majority of built-in functions.

Fixed passing of objects and numbers to functions via command syntax.

Added capability to call methods with command syntax:
  • In place of the command name, write the target object and method name separated by a dot. Var.Method and Var.Property.Method are both acceptable, but anything more complex (such as Var[x].Method or %Var%.Method) is not supported.
  • The return value is always discarded; there is no output variable.
  • All args are text by default.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

15 Sep 2014, 17:10

v2.0-a050-712e1d8

Major review of several areas of the code, with related bug-fixes, optimizations, and probably bugs.

Added support for binary zero in strings in expressions, and in objects.
Added support for comparing binary data using ==.

[fincs] Changed OnExit to accept a function.
[fincs] Removed OnClipboardChange and added a function like OnExit.
Changed ExpandExpression() to free object references after completion.

Optimized returning dynamically-allocated values from functions.
Revised GetKeyState and KeyWait.
  • Removed ACT_GETKEYSTATE, reducing code size and fixing "GetKeyState Joy%btn%" to return 0/1 instead of U/D.
  • Fixed JoyPOV to yield integer -1 when centered, not string.
  • Changed KeyWait to throw an error if KeyName is invalid.
Changed commands/functions to return HWNDs and styles as pure integers. Affects the following:
  • WinActive
  • WinExist
  • WinGetID
  • WinGetIDLast
  • WinGetList
  • WinGetStyle
  • WinGetStyleEx
  • WinGetControlsHwnd
  • ControlGet Hwnd
  • Gui +HwndVarname
  • GuiControlGet Hwnd
  • Gui Add, ..., +HwndVarname
  • MouseGetPos
A_ScriptHwnd returns a string due to a technical limitation, but in decimal for consistency.
Changed Func() to accept either a function name or a function reference.
Removed object -> address mode of Object(). ObjAddRef(addr := &object) can be used instead.
Changed ExitApp to pass ExitCode to the OnExit callback.
Changed OnClipboardChange() to affect script persistence.
Changed OnClipboardChange() to not immediately call the function.

Changed StrSplit() to raise an error for invalid delimiters.
Changed VarSetCapacity to throw whenever capacity is invalid/too high.
Changed File commands to throw an error if given invalid parameters.

Fixed X(,(y)) and X(,"%y%") incorrectly raising an error.
Fixed a crash occurring when return "string" returns to CallFunc().
Fixed return "just a string" to not literally include the quote marks.
Fixed simple % int args for ACT_METHOD.
Fixed optimization to not make A_Index/A_EventInfo non-numeric.
Fixed x.y to call rather than get, consistent with x.y,. Side note: standalone "x.y" expressions were originally disallowed. This was changed to allow lazy VB converts to use code like "App.Quit", which should still work, but will now also work with AHK Objects.
Fixed x.1 to call with an integer key, consistent with x.1().
Fixed method-commands to invoke the default base object when appropriate.
Fixed StrPut("", Encoding) - fixed by c3d844e, then broken by 855815e.
Fixed ACT_FUNC/ACT_METHOD to support % v:=1 and % v:={} ByRef.
Fixed throw str.
Fixed Abs()/Mod() to not overwrite params which might be string/object.
Fixed plain text args of ACT_FUNC/ACT_METHOD (broken by 69e9675).
Fixed some object reference leaks.
Fixed command-style calls with no params to not require an output var.
Fixed a memory leak occuring when RegExReplace throws an error.
Fixed RegEx Callouts to be able to throw exceptions or to Exit the thread.
Fixed several uses of strings in objects (broken by 8cd2072).
Fixed &byref_var_containing_int.

Merged v1.1.16.03 (plus a bug-fix).
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

16 Sep 2014, 06:51

v2.0-a051-be9cffc

Fixed math with non-numeric input to produce "", not its address.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

18 Sep 2014, 04:42

v2.0-a052-e27d2cb

Fixed var .= value corrupting memory when malloc() is used internally for the concatenation (broken by v2.0-a050). Due to an optimization, this only happened if there was insufficient space in var for the additional value. The fix also optimizes such cases to be even faster than they were prior to v2.0-a050.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

18 Sep 2014, 21:29

v2.0-a053-20abdda

Fixed %obj%() crashing the program in some instances.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

19 Sep 2014, 17:43

v2.0-a054-bf5edc2

Fixed some errors in Op_ObjIncDec (x.y++ and similar).
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

27 Sep 2014, 20:24

v2.0-a055-f5ec0e3

Fixed returning of ByRef vars.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

11 Oct 2014, 21:14

v2.0-a056-33fe326

Fixed commands to treat objects as empty strings (not garbage).
Fixed a crash occurring when a for-loop expression causes thread-exit.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

27 Dec 2014, 21:11

v2.0-a057-428b040

Merged v1.1.17.01.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

16 Feb 2015, 23:15

v2.0-a058-fa7ed04

Fixed COM errors to abort after an exception is thrown.
Fixed double deref assignment of built-in vars.
Added error message when assigning to a read-only var in an expression.
Removed Func[""]() - use Func.Call() instead. Function objects should implement a Call() method instead of __Call().
  • Changed %Fn%() to call Fn.Call() instead of Fn[""]().
  • Changed method dispatch to use Fn.Call(this) instead of Fn[this]().

Merged v1.1.19.03 (plus one fix).
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

11 Mar 2015, 06:23

v2.0-a059-efe5d5f

Merged v1.1.20.02.

Removed the legacy mode of OnMessage, so function names now act the same as function references. OnMessage(x, "MyFunc") registers MyFunc and OnMessage(x, "MyFunc", 0) unregisters it. OnMessage(x) and OnMessage(x, "") are now errors, since there can be any number of functions monitoring x. The command syntax no longer has an output var.

Fixed x.y (command with no args) being treated as GET in some cases.
Changed ComObjConnect to not require an output var.
Some minor refactoring, optimization and fixes for theoretical bugs.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

11 Mar 2015, 16:47

v2.0-a060-8abaf1c

Fixed errors relating to the v1.1.20.02 merge:
  • Crashes when an object's __delete should normally be called.
  • Fixed local output variables with command-style function calls.
  • Fixed load-time resolution of local labels with SetTimer and Hotkey.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

13 Mar 2015, 03:14

v2.0-a061-acaa766

Fixed for-loops (broken by v1 merge).
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha

14 Mar 2015, 05:54

v2.0-a062-e5d8419

Fixed stack_get debugger command crashing/failing when there's a built-in function or object operator ("<object>()" entry) on the call stack.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

20 Mar 2015, 23:33

v2.0-a063-d09e310

Fixed static x := 1 to assign an integer, not a string.
Merged v1.1.20.03.
lexikos
Posts: 5457
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AutoHotkey v2 alpha (UPDATES)

24 Mar 2015, 20:48

v2.0-a064-bfc6331

Changed RegRead/RegWrite/RegDelete to raise an error if parameters are invalid.
Changed assignments to raise an error if not given a variable.
Changed +(unary plus) to convert the value to a number if it is a numeric string (previously it was completely ignored).

Experimental:

Changed +=/-=/++/-- to treat empty target variable as zero.
Changed other invalid math operations to produce "NaN" instead of "", including divide-by-zero and math with empty or other non-numeric values.
Changed math functions to produce "NaN" on error instead of "".
Changed math functions to produce "NaN" when any parameter is non-numeric.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: SirRFI and 3 guests