Thoughts for v2.0


Perhaps remove the strings "On" and "Off" since they don't work intuitively in boolean expressions, and just use true and false. This applies to various built-in variables and possibly some commands. However, it may be useful to retain the ability of SetTimer to reenable a timer without changing its time interval. On and Off may also be more readable for Hotkey and some others.


Commands with sub-commands

Some of the new functions which replace sub-commands return 1 on success and 0 on failure (in addition to setting ErrorLevel), while others only set ErrorLevel. This should be rectified.

There are still some issues with the Control/ControlGet functions, which may or may not be resolved in v2.0 depending on "developer motivation":

The Thread command still has sub-commands.

Click / MouseClick

Rename MouseClickDrag, perhaps to MouseDrag?

MouseClick has been superseded by Click. Should MouseClick be removed? Should Click be renamed to MouseClick, for consistency with MouseMove?


For convenience, it should be possible to pass a Gui object to a WinTitle parameter instead of "ahk_id " Gui.Hwnd. Current technical limitations make this infeasible for commands which have not yet been internally converted to functions.

FileGetVersion: Some executables (including AutoHotkey) have a version string which has the same numeric values but different (more correct) formatting than what FileGetVersion returns, since it is based on a different (pure numeric) field in the PE header. If there is potential for built-in support for version strings to be added, FileGetVersion should probably default to the more correct string.

OnMessage: Someone (I was unable to find the post) suggested the parameter order for the callback functions be changed, possibly because hwnd is needed more often due to the removal of A_Gui.

SoundGet/SoundSet: The component and control types are currently based on the Mixer API, which is only used on 2000 and XP. These should be updated to closer match the capabilities of the Vista+ API. Support for SoundGet/SoundSet on 2000 and XP may be dropped entirely to simplify this.

WinTitle and Window Groups

Background info: Each window group consists of a list of window specs. A window spec in v1 consists of WinTitle, WinText, ExcludeTitle and ExcludeText. Window specs are evaluated in the order they were added to the group. For convenience, "rule" means "window spec" in the text below.


Problems in v1:

The most likely solution is to introduce "negative" or "exclusive" rules. Rules are evaluated in the order they were added to the group, ending with the first rule (positive or negative) that matches the window. This provides the following benefits:

There are different ways this could be achieved:

Chris' comments:

ExcludeTitle doesn't support ahk_pid and similar things. All it does is what the help file says: "Windows whose titles include this value will not be considered." The reason for this is that the added code size doesn't seem justified given how rarely ExcludeTitle is used.

In light of the above, the second option above seems preferable.

In either case, a negative rule has no effect if there aren't any positive rules following it, because the absence of any subsequent positive rules means that the window won't be a match anyway. Therefore, for convenience, a group could match all windows by default if the last rule is negative. That way, if group N contains only negative rules, ahk_group N matches all windows except those excluded by the group (instead of always matching nothing at all).


An oft-requested feature is to allow global settings such as SetTitleMatchMode, DetectHiddenWindows and DetectHiddenText to be overruled temporarily for a given WinTitle or command. At the moment, the most likely form it could take is Title ahk_mode 3 ahk_dhw 1. Implementing this in a later release is unlikely to affect existing scripts; therefore this is not currently planned for v2.0.

Binary Data

Strings in v2-alpha can contain binary zero, but there is room for improvement. SubStr is able to return a portion of the data, but with a granularity of 2 bytes (because of UTF-16). Scripts which work with variables and array elements as buffers (with VarSetCapacity/SetCapacity) have no way to set the length of meaningful data - i.e. VarSetLength or similar.

A more general approach would be to create a string of n length, assign that to the variable or object, then manipulate the content. However, with the current implementation, that might require copying the string and redundant memory allocations.

Scripts use VarSetCapacity for two purposes:

The latter case should use VarSetLength, since the entire length of the structure is meaningful. This would allow a struct to be passed by value (copied) or returned from a function. VarSetCapacity would then only be used for strings; maybe the capacity should be measured in characters rather than bytes. Alternatively, there can be separate functions for "Byte" and "Str" length/capacity.

Boolean: Strings beginning with Chr(0) are currently false, because the boolean checks assume a zero-terminated string rather than a binary counted one. It may be better to treat such strings as true. On the other hand, relative operators (< > etc.) currently only compare up to the null-terminator. Must take care that it is consistent with numeric treatment of strings with chr(0); i.e. if ("0" chr(0)) == 0, then it must be false.

Expression Operators

Although in and contains are already reserved in v2-alpha (so adding them later won't break anything), v2 might seem incomplete without them, since users converting existing scripts from v1 (or just used to using v1) will need to find some alternative that works in v2. They should probably be implemented before the v2.0 release, and they should be updated to be more modern (allow arrays).

Current usage: if var [not] in/contains MatchList. MatchList is a comma-delimited list. Var contains a string.

It seems logical to allow an array as a direct substitute for MatchList. Someone suggested that the new operators should never accept a comma-delimited list, but in that case a string would be interpreted one of the following ways:

  1. An error.
  2. Equivalent to a single-element array. That would mean:
  3. Equivalent to an array of the string's individual characters. That would mean:
  4. Having different meaning depending on the type of operand. Seems confusing. For example:

If arrays are supported on the left side of contains, how would that work? Traditionally the difference between in and contains is that in does a direct comparison of the value while contains does a substring match. Would arr1 contains arr2 search for each element of arr2 as a substring of each element of arr1? Or check for the existence of any common values between the two? Or all? Or check whether the exact sequence of values in arr2 exists within arr1 as a subset? The last option would be analogous to InStr(str1, str2), but not str1 contains str2.

Some (not very relevant) discussion here:

between probably won't be implemented at any stage. An alternative could be to allow operator chaining as in Python and Perl 6, where x < y < z is equivalent to (x < y) and (y < z). However, that would mean that parentheses would change the meaning of < (which doesn't seem right), such as in x < y < z vs (x < y) < z, because the latter case would compare the result of x < y (true or false) to z. Some users already try x < y < z and wonder at the result, so if it isn't implemented, maybe chained operators should be detected and cause a warning/error. (But if chained operators would be complicated to detect, cost vs benefit seems to be in favour of implementing chaining.)


Syntax for properties vs methods

Built-in objects and user-defined objects are inconsistent in what syntax they support for properties. This should be rectified where possible.

How it works now:

What should probably be changed:

Inconsistent properties to consider changing:


Meta-functions are commonly misunderstood, and should probably be simplified. Random ideas:


Objects now support binary zero in string values, by storing the length of the string. However, now only data up to the string length is preserved when cloning the object (consistent with retrieving the value from the object as a string, such as to assign to another object). There should be some way to set the length of data, such has Object.SetLength(Key, Length). For clarity (and to avoid confusion with Object.Length), it might be better to have SetStrLen and SetByteLen. Also consider that similar functions might be needed for variables, to better support binary data.

new MyClass[a,b,c] could be reserved as a more convenient way to initialize a specialised array/collection type (new MyClass{a:b} is already "reserved" by way of being treated as a syntax error). Currently MyClass[a,b,c] could be a class to instantiate, but it's unlikely to have been used much (if at all), and is inconsistent with the v1 policy of requiring a class name after the new operator. v1 treats new x[y](z) as new c1 where c1 = x[y](z), while v2-a076 treats it as new c2(z) where c2 = x[y].

SafeArray objects should perhaps gain a .Length() method for consistency with plain Objects.

ComObjConnect() events currently dereference ByRef VARIANTs automatically (since some languages pass this whenever a variable is passed from script), which prevents the function from being able to pass back a value in some cases. We could either a) pass a ByRef wrapper allowing assignments such as param[] := value or b) automatically pass a variable and update the VARIANT after the function is called. Other (i.e. non-VARIANT) ByRef combinations are not dereferenced, and param[] := value is already supported in v1.1.17+.


Allow base to be defined as a nested class (and actually set the base class), so that meta-functions and properties can be easily defined for the class itself, within the class.

Make base a reserved word in class methods. Currently it is given special meaning when followed by . or [, except when the variable base has been assigned a value. Reserving the word simplifies the language and may improve performance.

If base is reserved everywhere, it could be used for calling an overridden built-in function (such as base.WinMove(x, y) in a redefinition of WinMove).


Random ideas that don't seem particularly relevant to v2.0.

Allow the script to define classes String and Number with methods and properties for all strings or numbers. Currently this is done by setting properties of the "".base object, but this affects all types of values except objects.

Allow the script to define global methods and properties for all objects, perhaps via an Object base class. By default this class would contain built-in methods such as Insert, allowing them to be redefined the same way that user-defined methods are. For example, a user-defined Insert method might call base.Insert(value) instead of ObjInsert(this, value).

Both of the above may require some way to append to an existing class, which may also be useful for user-defined classes. This could be allowed simply by repeating class ClassName {} or with an additional keyword for clarity, such as class ClassName extended {}. The keyword might imply that the initial and extended definitions must be placed in that specific order (rather than having two similar definitions which can be placed in any order), which mightn't be ideal. Another option is to allow ClassName.MethodName() declarations outside classes, allowing existing classes to be extended (and also allowing more flexibility over the organization of code).