AutoHotkey dll Module

Auto Hotkey

AutoHotkey.dll module

Table of Contents

Why do we need an AutoHotkey Module

Multi-threading: AutoHotkey is not designed for multi-threading naturally and most likely it will be never implemented. Using AutoHotkey.dll we can stil run multiple scripts in one process, on a multi-core system we can even run multiple scripts at the same time. To do so, AutoHotkey module also needs to be loaded multiple times. Note for this you will need to use MemoryModule or multiple dlls by copying and renaming AutoHotkey.dll for example to MyScript1.dll, MyScript2.dll ...

AutoHotkey Module is running in its own context, using separate memory, functions and variables, this allows to access, read and write its memory / variables from another thread. AutoHotkey Module exports several functions that allow various operations to create and manipulate the new thread.

Use AutoHotkey in other programms: AutoHotkey Module can be also used in other programming languages like VB, C#, C++, Python, Lua and many more. Programms that do not support loading a dll naturally can use the COM Interface of AutoHotkey.dll.

AutoHotkey COM Interface: AutoHotkey.dll can be also loaded and manipulated using its COM Interface. Before using this Interface, AutoHotkey.dll needs to be registered:

regsvr32 "C:\Program Files\AutoHotkey\AutoHotkey.dll"
To unregister AutoHotkey.dll use:
regsvr32 /u "C:\Program Files\AutoHotkey\AutoHotkey.dll"

AutoHotkey_H additionally supports loading unregistered dlls using ComObjDll.

Internally COM Interface always use MemoryModule to create a new thread, this allows loading the same module multiple times. AutoHotkey.dll automatically frees the module when COM object is released.

Reload script but keepProcess running

Using AutoHotkey Module we can share variables/objects/memory between thread. For example we can create all reqiured variables in main thread and share them to AutoHotkey Module using Alias function. Whenever a reload is required (e.g to accept new hotstrings and hotkeys) we can reload the AutoHotkey module only and share the variables again.