AutoHotkey v2 alpha (UPDATES)

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


09 Oct 2019, 05:52


Particularly important:

Removed the new operator; use

Changed objects to throw an exception when attempting to retrieve an undefined property.

Simplified SetTimer: removed "On"/"Off"/"Delete", the ability to disable/re-enable timers (which requires keeping them in the global timer list), and inconsistency between actual functions (Func) and function objects. Delete a timer by passing 0.

Changed hotkeys without #/! to never mask release of Win/Alt, rather than doing so only if Win/Alt is physically down (inconsistent with remapped Win/Alt keys).

Added IsSet(Var).

Added primitive types and Any to the type hierarchy. Added prototypes for Any, Primitive, String, Number, Integer and Float; not yet accessible except through a value of the applicable type. All values are based on Any (except ComObjects) and can use HasBase, HasProp, HasMethod and GetMethod, which are now also functions. Define/Delete methods can't be called directly on the prototypes as they are not derived from Object.Prototype.

Changed BoundFunc to merge parameter lists when bound args are omitted.

Changes and additions relating to DllCall (and native COM interfaces in particular):
  • Added Ptr property to VT_ARRAY, VT_BYREF and VT_UNKNOWN ComObjects, allowing them to be passed to DllCall more easily.
  • Added HRESULT return type for DllCall (throws on failure).
  • Added ComCall as a shortcut for calling COM interface methods.
  • Changed DllCall "str" to detect overwrite of null-terminator.
  • Changed Str*, WStr* and AStr* to output value of new pointer.
  • Changed DllCall Ptr*, Obj to assign to Obj.Ptr rather than Obj. This allows constructs such as DllCall(..., "Ptr*", unk :=, which reduces repetition and improves maintainability compared to DllCall(..., "Ptr*", punk), unk :=
  • Changed DllCall to throw if a numeric-type parameter is non-numeric. In particular, if the * or P suffix is used for output parameters, the output variable is required to be initialized. This improves robustness and compatibility with #Warn.
Changed internal use of Call to bypass __Call, and improved compatibility with COM function objects that handle DISPID_VALUE, such as JScript functions.

Changed FileOpen to throw an exception on failure.
Changed Object.New(with_params) to throw if there's no __New.
Changed concatenation with an object to produce an error.

Improved error-reporting for invocation of unknown property/method.

Fixed Menu prototype not inheriting from Object.Prototype.
Fixed debugger skipping enumerated items when properties are present.
Fixed For onevar in e to call e.__Enum(1) rather than e.__Enum(2).
Fixed CStringA buffers not being freed by DllCall if an exception is thrown.
Fixed handling of ComObj[] and ComObj.__Item.
Fixed incorrect error messages for x.y[z] when [z] is impossible.
Fixed issues with multiple arrow functions in the same scope.
Fixed Object() to throw when given an odd number of parameters.
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


16 Nov 2019, 20:18

Main breaking changes:
Removed support for Windows XP.
Removed the key names Return and Break.

Changed WinTitle to allow passing a HWND as an Integer or object with a HWND property. DetectHiddenWindows is ignored in such cases.

Changed GroupDeactivate to be more consistent with OS task switching, and generally handle windows which own other windows more intelligently.
Changed TrayTip to specify the current small tray icon when the NIIF_USER (0x4) flag is used, and the large icon when NIIF_LARGE_ICON (0x20) is also used.
Simplied VK/SC conversion; improved compatibility with custom layouts.
Changed the way Input handles the primary end key of VKs with two names.
Fixed GetKeyName to return non-Numpad key names when given a VK.
Fixed File.WriteXXX(n).
Simplified AltGr detection to reduce code size.
Removed obsolete remap destination exceptions and fixed x::vk13 (Pause).
Merged latest changes (90b5c2ac) from v1 branch.

Changed Group(De)Activate/Close to throw if group name is invalid.
Improved validation of function objects by various functions/methods, for early detection of errors (such as passing a function object which does not accept the right number of parameters).
Fixed objx.%objy% to throw an exception.
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


07 Dec 2019, 17:09

Fixed InputHook.KeyOpt sometimes using vkNN behaviour for single chars.
Fixed crashes caused by manipulating InputHook properties (by lvalkov · Pull Request #153)
Merged v1.1.32.00.
Fixed omitted parameters in variadic calls to use default value.
Fixed [Array].Has(i) to return 1 rather than i when true.

Revised SoundGet/SoundSet.
  • Remove unsupported control types (everything except Volume/Mute was supported only on XP).
  • Remove legacy mixer component types.
  • Let components be referenced by name and/or index.
  • Let devices be referenced by name-prefix and/or index.
  • Split into separate Volume and Mute functions.
  • Add SoundGetName for retrieving device or component name.
  • Add SoundGetInterface for retrieving COM interfaces.
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


27 May 2020, 05:00

Added CaseSense property to Map.

PR #165 (Helgef): x**y - Where x and y are integers and y is positive, the power operator now gives correct results for all inputs if in range, where previously some precision was lost due to the internal use of floating-point math. Behaviour of overflow is undefined.

Fixed OnMessage failing to Release any Closure passed to it.
Changed FileOpen to give a more sensible error message for * or ** when there is no handle.
Fixed arrow functions in class body.
Fixed crashes when using a built-in var with Switch/Case.
Fixed a misleading error message when an invalid callback is passed.

PR #151 (Helgef): #DllLoad no longer affects calls to LoadLibrary for load-time DllCall optimizations.
PR #158 (Ragnar): Fixed SoundSet functions crashing the program.
PR #160 (HotKeyIt): Fixed some memory leaks and the length of ComObjType's return value.
PR #166 (Helgef): Fixed pre "++/--" with "longer than one" property gets that include dot percent.
PR #172 (Helgef): Fixed crashes relating to InputHook match list.

Merged bug fixes from v1 branch.
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


06 Jun 2020, 05:48

Removed ErrorLevel. All error conditions that were previously reported via ErrorLevel now throw exceptions, with generally more descriptive messages. See v2-changes (ErrorLevel) for details.

Removed Input (see v2-changes).

Replaced VarSetCapacity with VarSetStrCapacity(var[,strlen]).

Changed InputBox to return an object.
Fixed InputBox reverting to system font.
Removed the explicit limit on the number of InputBox dialogs.
Changed InputBox W and H to exclude non-client area.

Added the capability to continue the thread after an error dialog is shown, or via OnError. For details, see v2-changes (Continuable Errors) and the OnError documentation. Note that the signature of OnError callbacks has changed.

Revised error handling and error messages in some cases. See GitHub for specific changes.

Changed MouseClick, MouseClickDrag, LButton and RButton to be unaffected by button swap.
Improved incoming COM calls to transparently support ByRef parameters.
Fixed return value of RegEx callouts being ignored.
Changed Run to use full string (not substring) match for Options.
Changed GroupActivate to return the HWND of the window it attempted to activate.
Changed IniRead to return Default on failure even if Key was omitted.
Changed MonitorGet/MonitorGetWorkArea to return the monitor number.
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


11 Jun 2020, 17:08

There are numerous compatibility-breaking changes. Read carefully.

Merged pull requests #175, #176 and #177 from HelgeffegleH/AutoHotkey_L
  • Renamed #If to #HotIf and #IfTimeout to #HotIfTimeout.
  • Replaced Hotkey "If" with HotIf, Hotkey "IfWinActive" with HotIfActive, etc.
  • Changed hotkeys and non-autoreplace hotstrings to use functions rather than labels. Use braces rather than return.
    Note: Functions are assume-local by default, even for single-line hotkeys.
Removed support for labels with the Hotkey/Hotstring function. Labels are now only used by goto, gosub, break and continue.

Removed ComObjError and changed COM error format to be consistent with Win32 errors and slightly more readable.
Changed ComObjCreate and ComObjQuery to return a wrapper object even when given an IID.
Changed ComObjQuery to permit the first parameter to be a custom object with Ptr property.

Removed Var buffer mode of NumPut, NumGet, RawRead and RawWrite (always pass a Buffer or address).
Note: Removal of the old "deprecated" NumPut syntax was planned but forgotten. When updating scripts to avoid the var buffer mode, please use the new syntax.
Removed A_IsUnicode (it can be redefined as global A_IsUnicode := 1 for v2; or v1 and v2 scripts may use StrLen(Chr(0xFFFF))).
Converted True/False variables to keywords.
Renamed Clipboard to A_Clipboard.
All "virtual" vars now have the A_ prefix.
Fixed built-in variables to return numbers as Integer rather than as String.
Removed checks for clipboard remaining open; clipboard should always be closed immediately after use.

Added GuiCtrl.Redraw() and removed Draw parameter of GuiCtrl.Move().
Replaced Options with X, Y, Width, Height for GuiCtrl.Move().
Replaced Gui/GuiCtrl.Pos/ClientPos with GetPos/GetClientPos([x,y,w,h]).
Added Gui.Move([x,y,w,h]).
Removed support for delimited strings and +Delimiter; use an Array instead.
Removed redundant (undocumented) Choose option for MonthCal.

Replaced &value (address-of) with StrPtr() and ObjPtr(). No direct replacement is given for &numberVar.
Replaced Object(Ptr) with ObjFromPtrAddRef(Ptr).
Added ObjPtrAddRef(Obj) and ObjFromPtr(Ptr).
Removed ObjClone and ObjDeleteProp (but not the methods).

Removed "0 is the same as 0.5" behaviour from Wait functions. Specifying 0 will give the shortest possible wait.
Changed For and F(p*) to support __Enum on primitive values if defined.
Fixed CallbackCreate((*)=>'',, 1) being flagged as an error due to MaxParams < 1.
Removed Slow mode of PixelSearch and Mode parameter.
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


19 Jun 2020, 16:41

Main breaking changes:

  • x is typestring -> istypestring(x) (e.g. isNumber(x), isXDigit(x), etc.)
  • base.method() -> super.method()
  • GuiCreate -> Gui.New, MenuCreate -> Menu.New, MenuBarCreate -> Menu.New
  • Static variable initializers do not "auto-execute"
  • Non-literal property names in object literals require %..% (e.g. {%nameVar%: valueVar}
  • ObjRawGet, ObjRawSet -> Obj.GetOwnPropDesc, Obj.DefineProp (with different usage)
  • Removed "On"/"Off"/"Toggle" - use 1/True/0/False/-1
    (excludes functions which also accept other strings: Hotkey, Hotstring, Set*LockState, BlockInput)
  • #HotIf can now use ThisHotkey, and cannot reference undeclared globals (consistent with hotkeys)
Details and other changes:

Added f(p:=unset) parameter default, which allows functions to use IsSet(p) to detect whether a parameter was omitted.

Changed the default script codepage to UTF-8.

Split x is typestring into functions such as isNumber(), with the is operator's only remaining use being x is classobj (type checking).

Replaced base.method() with new reserved keyword super.
  • Always acts like a keyword, not a variable-keyword hybrid.
  • Attempting to use it where it wouldn't work (outside a class) is detected as a load time error.
  • Should be no confusion between super.method() and obj.base.
Implemented the Gui, Menu and MenuBar classes. Use Gui.New(), Menu.New() and MenuBar.New() in place of GuiCreate(), MenuCreate() and MenuBarCreate(), which have been removed.

Changed Gui to allow subclass instances to be their own event sinks.
  • Subclass must call super.__new(opt, text, this) from __new.
  • The circular reference is not counted, so will not cause leaks.
  • The redundant Gui parameter is omitted for main Gui events.
Changed how (local) static variables are initialized.
  • Each initializer is executed only if/when it is reached during execution.
  • Since the function has been called, parameters, A_ThisFunc and closures are available.
  • If execution reaches it again, it is skipped.
  • Multiple declarations are allowed, and each one may execute once.
  • For auto-execution, use the auto-execute section (which is no longer interrupted by hotkeys, and need not be terminated with a return).
Changed object literals to be stricter and more consistent with .prop.
  • {a:b} -> {}.a := b
  • {%v%:b} -> {}.%v% := b
  • Any other kind of expression to the left of : is an error.
Extended DefineProp and GetOwnPropDesc for use with value properties.
Removed ObjRawGet and ObjRawSet.

Changed Menu.Add(t) to not default to using t as a function name (in other words, the second parameter is required when creating a new item).

Removed the use of SPI_SETFOREGROUNDLOCKTIMEOUT on startup.
  • My recent testing on Windows 10 indicated it was ineffective, even when a separate process verifies the change occurred.
  • User reports (and common sense) indicate that if it works, it allows the focus to be stolen by programs which aren't specifically designed to do so.
  • It can be replicated in script easily:

    Code: Select all

    DllCall("SystemParametersInfo", "int", 0x2001, "int", 0, "ptr", 0, "int", 2)
Changed WinActivate to send {Alt up} on its first failed attempt.
Testing on Windows 10.0.19555 indicates this improves the reliability of all subsequent attempts, thereby preventing buttons from flashing more than once per script process.

Changed OwnProps() to skip dynamic properties which lack a getter in this or which require parameters, but only if a value was requested (i.e. they are not skipped when using a for-loop with one variable).

Removed the rarely-used capability to use dynamic output variables with For and Catch, to simplify the implementation.

Removed On/Off/Toggle from most variables/functions.
  • #UseHook and #MaxThreadsBuffer allow 1, 0, True and False. (Unlike the others, they do not actually support expressions.)
  • ListLines allows blank or boolean.
  • ControlSetChecked, ControlSetEnabled, Pause, Suspend, WinSetAlwaysOnTop, and WinSetEnabled allow 1, 0 and -1.
  • A_DetectHiddenWindows, A_DetectHiddenText, and A_StoreCapsLockMode use boolean (as do the corresponding functions).
Simplified Pause().
  • If the first parameter is omitted or blank, it pauses the current thread, for ListVars/Pause and similar.
  • Any other value operates on the underlying thread. In particular, this allows #p::Pause(-1) to toggle pause (again).

Enabled #Warn UseUnset by default - to be converted to a continuable error at some point.

Changed top-level classes to be constants, prohibiting class overwrite (and removed #Warn ClassOverwrite).

Changed uninitialized.x() to always be an error.
This usually produced an error dialog with 'This value of type "String"' (unless String has x()), which is a bit misleading/not very informative. Previously there was no "unset" warning even with #Warn.

Changed continuable error dialogs to discourage continuing.
Changed control flow statements to throw if a parameter unexpectedly resolves to an object. For example: Loop {}
Changed FileCopy/FileMove to throw if there are no wildcards in the source path and no file is found.
Changed InStr to throw if Needle is zero-length.
Added validation to Gui.Move() and GuiControl.Move().

Merged pull requests #181 and #182 from Helgef:
  • #HotIf now implicitly creates an assume-local function with one parameter: ThisHotkey. For now, it cannot reference global variables without a global declaration (consistent with hotkeys).
  • Bug fixes relating to #HotIf.
Fixed Menu.Add(t, obj, opt) not updating callback if item exists.
Fixed Menu.Add(t) to throw "parameter #2 must not be blank" rather than "invalid parameter #2".
Fixed empty Clipboard variable being created on startup.
Fixed WinSetEnabled detecting failure incorrectly.

Merged v1.1.33.00 (release delayed due to issues with the certificate I use to sign the installer).
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


30 Jun 2020, 17:09

Split ControlGetList() into ControlGetItems() and ListViewGetContent().
  • ControlGetItems() has no Options parameter, and it returns an array.
  • ListViewGetContent() is unchanged; possibly to be replaced in a (much) later release.
Revised Control functions dealing with selected item/tab.
  • Renamed ControlChoose to ControlChooseIndex, and added ControlGetIndex.
  • Merged ControlGet/SetTab into ControlGet/ChooseIndex.
    Note: Choose rather than Set due to multi-select ListBox.
Renamed all Control functions which operate only on Edit controls.
  • ControlGetSelected -> EditGetSelectedText
  • ControlEditPaste -> EditPaste
  • Others just replacing Control with Edit
Removed the old mode of NumPut and made Type mandatory for NumGet/NumPut.

Changed ** exponentiation to be right-associative.

Changed super-global and class declarations to be mutually-exclusive.
Improved error messages for conflicting variable declarations.
Improved error messages for invalid assignment to a constant.
Enabled #Warn Unreachable, MsgBox by default.
Changed expressions like MsgBox(), nope to trigger #Warn UnSet.
Improved validation of Background GuiControl option.

Fixed ControlClick "x55 y77" to not always require the Pos option.
Fixed some reference counting errors for Class objects.
Fixed Gui to allow non-Gui members to be invoked prior to construction.

Merged v1.1.33.00 (actual release).

SHA256 hash
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


05 Jul 2020, 05:43

This release has some major bugs. Get v2.0-a115 instead.

The following limits have been removed by utilizing dynamic allocations:
  • Maximum line or continuation section length of 16,383 characters.
  • Maximum 512 tokens per expression (MAX_TOKENS).
    Arrays internal to the expression evaluator which were sized based on MAX_TOKENS are now based on precalculated estimates of the required sizes, so performance should be similar but stack usage is somewhat lower in most cases. This might increase the maximum recursion depth of user-defined functions (allow more recursion than before).
  • Maximum 512 var or function references per arg (but MAX_TOKENS was more limiting for expressions anyway).
  • Maximum 255 specified parameter values per function call (but MAX_TOKENS was more limiting anyway).
Removed the automatic Exit between the main script and auto-includes.
Changed Picture control to keep current image when setting Value fails.
Changed OwnProps two-param mode to skip dynamic properties on class prototypes.
Improved most "type mismatch" error messages.
Changed label syntax to permit only the standard name characters.

Changed FileSelect to return an Array when the M option is used.
Changed FileSelect to use IFileDialog.
Removed default *.txt filter from FileSelect.
Fixed FileSelect to preserve spaces inside complex filter patterns like "prefix with space*.ext".
Added D (directory/folder) option to FileSelect.

Fixed Gui.New().Destroy() in static __new() to not exit the script.
Fixed escaping of quotes in fat arrow functions.
Fixed x.y[z] to behave like (x.y)[z] when x.y is a primitive value.

SHA256 hash
Posts: 6869
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos


Yesterday, 05:40

Fixed lines reachable by local label being flagged as unreachable.
Fixed continuation expressions.
Fixed Gui.Prototype.Add ignoring param #3 for Tab2 and Tab3 controls.
Fixed Tab3 display area not adjusting when a tab row is added/removed.
Fixed remappings.

SHA256 hash

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 19 guests