Thoughts for v2.0



As commands and functions are still internally distinct in the current v2 alpha, defining a function with the same name as a command overrides the command only for the function() style of calling; i.e. the command style still calls the original command. This should be changed.

Commands with sub-commands

The remaining commands which have sub-commands are: DriveGet, Drive, Control, ControlGet, GuiControl and GuiControlGet.


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?

Error Handling

Note that some changes have already been made which won't be covered here.

Errors in math operations

In v1, math operators silently produce an empty string in the following cases:

It's uncertain whether behaviour under these conditions should stay as is. The alternatives are to throw an exception or to produce some other non-numeric value, such as the string "NaN" (reminiscent of JavaScript's special NaN value). The latter seems like a worse fit for AutoHotkey.

Additionally, there have been debates about whether empty strings should be treated as 0. This will most likely not happen, with the exception of += and -=, which have been changed to treat an empty variable as 0, since these are where the policy is most commonly convenient.

Errors in math functions

If the behaviour of math operators is changed (to do something other than return an empty string on error), math functions such as Round() should be changed accordingly.



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


Object.GetAddress(key) should return the address of an empty string if that's what Object[key] contains, since some scripts may want to assign a string and then pass its address to DllCall or similar. Currently such scripts need to call SetCapacity after assigning an empty string.

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.

Some users have requested Object.Count(). Usage could be Object.Count([MinKey, MaxKey]), returning the number of key-value pairs in that range (or in total if there are no parameters).

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).


These were tentative ideas. Encouraging "OO" syntax is not my intended direction for AutoHotkey (especially with numbers and strings), so these probably won't be implemented.

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).