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 still 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 AutoHotkey1.dll, AutoHotkey2.dll ...

AutoHotkey Module is running in its own context, using separate memory, functions and variables. You can access, access variables and objects 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. Programs that do not support loading a dll naturally can use the COM Interface.

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.