Version AHK_H 2.0-beta

https://autohotkey.com

© 2021 Hotkeyit, Steve Gray, Chris Mallett, portions © AutoIt Team and various others

Software License: GNU General Public License

AutoHotkey_H New Features [home]


Commands / Functions / Directives
#DllImportCreate an alias function for a dll function that allows to omit parameters and use default values.
It can also load pure machine code supplied as hex string, see example.
#TargetControlErrorDon't throw error when target control is not found.
#TargetWindowErrorDon't throw error when target window is not found.
#UseStdLibExperimental feature to automatically load a functions from standard library.
#WindowClassMainChange main window class from AutoHotkey to something different.
#WindowClassGuiChange Gui window class from AutoHotkeyGUI to something different.
AliasCreate ByRef variable or share variables to other threads in a multi-thread environment.
BinRunRun executable file from Memory.
BinToHexConvert binary data to Hex string.
CastConverts a value from one data type to another data type.
CreateScriptCreate script from main script for NewThread, AutoHotkey.dll, BinRun or DynaRun.
CriticalSectionCreates a Critical Section Structure and returns its pointer. Use EnterCriticalSection and LeaveCriticalSection to Enter and Leave the Critical Section.
Critical Section is requred for multi-threading environment.
CryptAESEncrypt and Decrypt data.
DirGetParentGet parent directory of a file or directory.
DynaRunRun code dynamically in new AutoHotkey process.
ErrorMessageGet error message string of A_LastError.
FileReplaceSimilar to FileAppend but replaces the file if it exists.
FindFunc (low level)Get a pointer to a Function.
FindLabel (low level)Get a pointer to a label.
GetEnvUse GetEnv to retrieve all environment variables to an object.
GetProcessParameterRead parent pid, command line parameter or working directory of a process.
HexToBinConvert Hex string to binary memory.
HIBYTEGet high byte from a value.
HIWORDGet high word from a value.
IsBOMCheck if a file has byte order mark.
LOBYTEGet low byte from a value.
LOWORDGet low word from a value.
MacroCreate a macro instead of a function. Macro will use caller's scope for all variables except for parameters.
MAKELANGIDMake LANGID.
MAKELCIDMake LCID.
MAKELONGMake LONG.
MAKELPARAMMake LPARAM.
MAKELRESULTMake LRESULT.
MAKEWORDMake WORD.
MAKEWPARAMMake WPARAM.
MCodeHCreate machine code function.
NewThreadCreate a new thread 'without' using AutoHotkey.dll.
OnMessageWatch for messages only for specified hwnd. Omit function parameter when deleting OnMessage to delete all registered functions for Message && HWND combination.
ProgressProgress function as in AutoHotkey v1.
ResDeleteDelete a resource in executable file.
ResDllCreateCreate a resource only dll file.
ResExistCheck if a resource exists in executable file.
ResPutAdd a resource to executable file from memory.
ResPutFileAdd a file to resources of executable file.
SendSleep functionality for Send command, for example Send 123{100}456 would send 123 then sleep for 100 milliseconds and send 456.
sizeofReturns the size in bytes for default data type, structure or structure definition, for example MsgBox % sizeof("TCHAR").
SplashImageSplashImage as in AutoHotkey v1.
SplashTextOn / OffSplashTextOn as in AutoHotkey v1.
StrBufPut an encoded string into a variable.
SwapSwaps two variables.
ThreadObjCreate a new thread 'without' using AutoHotkey.dll, based on COM using ObjShare.
ToCharConvert an integer to signed char.
ToIntConvert an integer to signed integer.
ToShortConvert an integer to signed short.
ToUCharConvert an integer to unsigned char.
ToUIntConvert an integer to signed integer.
ToUShortConvert an integer to unsigned integer.
WinApiUse WinApi functions as if it was a build-in function.
Zip Functions Various zip functions to compress and uncompress files or data in memory. ZipCreateFile, ZipAddFile, ZipCloseFile, UnZip, ZipCreateBuffer, ZipAddBuffer, ZipCloseBuffer, UnZipBuffer, ZipRawMemory, UnZipRawMemory, ZipInfo, ZipOptions, ZipAddFolder
Gui Gui related features
Auto positioning and resizing of controls

Controls can be automatically positioned and resized when Gui is resized. Controls will be positioned and resized relatively to the initial size of Gui (Gui, Show).
The initial size of controls becomes the smallest size it will ever shrink to.
Resizing and positioning values can be followed by decimal number (e.g. 2 or 0.5) as well as fraction of an integer (e.g. 1/3), negative values are also supported.
When no value is given it defaults to 1, so ax, ax1 and ax1/1 do the same thing.
Note: the order in which controls are created might be important when position of previous controls needs to be considered.

The following auto position options are supported:

AX: Move the control horizontally by a specified amount when the Gui changes width.
For example: if the Gui width sizes up by 100px, a setting of ax1/2 would mean that the control would move to the right by 50px.

AY: Move the control vertically by a specified amount when the Gui changes height.
For example: if the Gui height sizes up by 100px, a setting of ay1/5 would mean that the control would move down by 20px.

AXP and AYP: Move the control by the same amount that the previous control moved.

AXA and AYA: Move the control by the same amount that the previous control moved and resized so the control is placed right after or below previous control.

AXR and AWR: Reset horizontal repositioning.

AYR and AHR: Reset vertical repositioning.

The following auto size options are supported:

AW: Resize the control width by an amount relative to the change in Gui width.
For example: if control is 100px wide and the Gui width sizes up by 100 px, a setting of aw0.5 would mean that control would widen by 50px.

AH: Resize the control height by an amount relative to the change in Gui height.
For example: if control is 20px wide and the Gui height sizes up by 100 px, a setting of aw1/4 would mean that control would heighten by 25px.

AWA and AHA: Resize the control width or height by the same amount as previous control.

Gui Scroll options

Scroll: Enable vertical and horizontal Scroll bars for gui.

VScroll: Enable vertical Scroll bar.

HScroll: Enable horizontal Scroll bar.

Objects
#CriticalObjectSleepTimeSleep time between TryEnterCriticalObject calls when accessing CriticalObject. This affects CPU load.
#CriticalObjectTimeOutTime out for accessing CriticalObject. When time out is reached, an error message will be shown and current thread will exit.
ComObjDllCreates a COM Object from a COM dll.
VT_BOOL: ComValue(0xB,-1) = true, ComValue(0xB,0) = false, VT_EMPTY: ComValue(0x0,0) = false, VT_NULL: ComValue(0x1,0) = falseFor JSON support, these are considered True or False when used in if or ternary expression (in original AutoHotkey all are considered true).
CriticalObjectCreate multi-thread save object.
InputHook Option AWhen using option A, previous input or text set via MyInputHook.Input := Text will not be discarded, instead new input will be appended to the text.
DynaCallImports a Dll function and defines its parameters so we don't need to define on each call like in DllCall.
JSONParse a JSON string to Map or Array or convert enumerable objects to string (thanks thqby).
ObjByRefSave variables by reference in object.
ObjDumpDump an object to memory or file.
Object FeaturesAdditional object features:
UMap (unsorted map and properties) / UObject + UArray (unsorted properties)
Init Map object using another object: Map({a:1,b:2})
ObjLoadLoad a dumped object from memory or file.
ObjShareCreate multi-thread save COM IDispatch proxy object.
StructCreates C++ like Structure object that is accessed and modified using object syntax.
MemoryModule Allows loading a dll from Memory, e.g. Resource.
MemoryFindResourceSimilar to FindResource.
MemoryFreeLibrarySimilar to FreeLibrary for MemoryModule.
MemoryGetProcAddressSimilar to GetProcAddress for MemoryModule.
MemoryLoadLibrarySimilar to LoadLibrary but loads a dll from memory. This allows real multi-threading by loading loading a dll multiple times.
MemoryLoadResourceSimilar to LoadResource.
MemoryLoadStringSimilar to LoadString.
MemorySizeofResourceSimilar to SizeOfResource for MemoryModuel.
Variables
NULL New built-in, variable same as FALSE. Resolves to 0.
A_AhkDirreturns the path of current exe.
A_ArgsMapcontains a Map of parameters, where A_Args will have [param1, param2, param3], A_ArgsMap will have {param1:param2,param2:""}.
A_IsDllreturns 1 (true) if called from AutoHotkey.dll and FALSE/NULL/0 otherwise.
A_DllPathreturns the path of current module (dll or exe).
A_DllDirreturns the path of current module (dll or exe).
A_ModuleHandleEquivalent to GetModuleHandle(NULL) but returns the correct ModuleHandle for AutoHotkey.dll when using MemoryModule
A_ScriptStructreturns pointer to internal g_script structure.
A_GlobalStructreturns pointer to internal g structure.
A_MainThreadIDreturns ID of main exe or dll thread.
A_ThreadIDreturns ID of current thread.
A_ZipCompressionLevelGet or set compression level for Zip functions. Use 0 for lowest and 9 for highest compression.
DoubleToString and StringToDouble libraryInternal conversion and representation of doubles (thanks thqby).
Compiling
Compiling AutoHotkey
Ahk2Exe Custom version of Ahk2Exe compiler with support for AutoHotkey_H features must be used to compile AHK_H.
Resource Library You can include library functions in resource of exe or dll (Resource type must be "LIB", e.g. *LIB/BINRUN.AHK).
Additionally AutoHotkey.dll can load library functions from exe file automatically (Note both executables must be using same password if source is encrypted).
#UseStdLib Experimental feature to automatically load a functions from standard library.
Dynamic Library You can include/create code using a library function. E.g.
#include <urldownloadtovar:http://www.website.com/script.ahk> ;also full path to the library function can be specified.
Resource Compression and EncryptionAhk2Exe supports compression and encryption for resource files, AutoHotkey will decompress and decrypt the files internally automatically. UnZipRawMemory can be used to decompress and decrypt resources in Script.
AutoHotkey.dll Module
AutoHotkey.dllAutoHotkey Module allows AutoHotkey to be embedded into another applications. It provides AutoHotkey functionality that might be more difficult to implement in another language.
Exported Functions for AutoHotkey
addScriptAdd and optionally execute additional script/code from text/memory/variable. Use "#include MyFile.ahk" to add script from file.
ahkassignAssign a value to variable or pointer of variable.
ahkExecExecute some script/code from text/memory/variable temporarily.
ahkExecuteLineExecutes script from given line pointer.
ahkFindFuncFind a function and return its pointer.
ahkFindLabelFind a label and return its pointer.
ahkFunctionCall a function via SendMessage method.
ahkgetvarRetrieve a value from a variable.
ahkLabelGoto (PostMessage) or Gosub (SendMessage) a Label.
ahkPausePause Script.
ahkPostFunctionCall a function via PostMessage method (does not wait until function returns).
7-zip.dll Module
7-zip.dll7-zip.dll module for advanced compression and decompression tasks.
Other
Hotstring Changed Hotstring to send ending character so it can be seen by other threads. This allows sending hotstrings one after the other.
ahk_parent Allow to identify the right window if multiple window with same criteria exist, ahk_parent must be followed by space and Window Id. ahk_parent can be used in any Win... and Control... functions. For example WinActivate, ahk_class #32770 ahk_parent 0x3F4A5

Acknowledgements

A special thanks to Jonathan Bennett, whose generosity in releasing AutoIt v2 as free software in 1999 served as an inspiration and time-saver for myself and many others worldwide. In addition, many of AutoHotkey's enhancements to the AutoIt v2 command set, as well as the Window Spy and the old script compiler, were adapted directly from the AutoIt v3 source code. So thanks to Jon and the other AutoIt authors for those as well.

Finally, AutoHotkey would not be what it is today without these other individuals.

~ Chris Mallett