AutoHotkey.dll
AutoHotkey.dll was invented by tinku99 and enhanced by HotKeyIt, it is a custom build of AutoHotkey_L (by Lexikos).
AutoHotkey.dll can be used in other programming languages and allows multithreading in AutoHotkey.
GET AutoHotkey V1 PACKAGE HERE.
GET AutoHotkey V2alpha PACKAGE HERE.
DllCall(dll_path "\" "function","UInt/Str/...",...,"Cdecl ...")
Parameters
| Get started |
To use AutoHotkey.dll you need AutoHotkey.exe or anther program able to load and run a dll or use COM. In AutoHotkey.exe, AutoHotkey.dll is loaded using DllCall("LoadLibrary","Str","dllpath or name"), you can also use AutoHotkey.dll COM Interface. Other languages and programs that support loading dlls have similar functions. (python, c#/c++)
Each loaded AutoHotkey.dll will serve an additional thread with full AutoHotkey functionality.
To unload AutoHotkey.dll you can use DllCall("FreeLibrary","UInt",handleLibrary). To start the actual thrad you will need to use ahkdll or ahktextdll (exported functions). Click the link below to read more about ahkdll and ahktextdll. |
| Why AutoHotkey.dll |
Multithreading We can run multiple threads simultaneously by loading several dlls. For example you can use Input command to catch user input and perform your task in background so no Input gets lost and your code works uninterupted. It is even possible to use same variables and objects using Alias() function, but be careful, when variable gets reallocated because its memory increases and you are accessing it, your program might crash, therefore you can use CriticalSection() to avoid simultaneous access.
|
| AutoHotkey.dll Exported Functions |
ahkdll = start new thread from ahk file. (not available in AutoHotkey.exe) ahktextdll = start new thread from string that contains an ahk script. (not available in AutoHotkey.exe) ahkReady = check if a script is running. addFile = add new script(lines) to existing(running) script from a file. addScript = add new script(lines) from string that contains an ahk script. ahkExec = execute a script from a string that contains ahk script. ahkLabel = jump(GoTo/GoSub) to a label. ahkFunction = Call a function and return result. ahkPostFunction = call function without getting result and continuing with script immediately. ahkassign = assign new value to a variable ahkgetvar = get value of a variable ahkTerminate = terminate the script/thread (not available in AutoHotkey.exe) ahkReload = reload script ahkFindFunc = find a function and return a handle to it. ahkFindLabel = find a label and return a handle to it. ahkPause = pause the script. ahkExecuteLine = Execute script from certain line or get first/next line.
|
| AutoHotkey.dll COM interface |
AutoHotkey.dll includes a COM Interface so you can use AutoHotkey trough COM, see examples below. Following interfaces are available: AutoHotkey V1: - AutoHotkey.Script = last registered (Unicode/Ansi/X64) - AutoHotkey.Script.UNICODE = unicode win32 - AutoHotkey.Script.ANSI = ansi win32 - AutoHotkey.Script.X64 = unicode x64 AutoHotkey V2: - AutoHotkey2.Script = last registered (Unicode/X64) - AutoHotkey2.Script.UNICODE = unicode win32 - AutoHotkey2.Script.X64 = unicode x64 |
Return Value
See function help.
Remarks
None.
Related
ahkdll, ahktextdll, ahkReady, addFile, addScript, ahkExec, ahkLabel, ahkFunction, ahkPostFunction, ahkassign, ahkgetvar, ahkTerminate, ahkReload, ahkFindFunc, ahkFindLabel, ahkPause, ahkExecuteLine, Alias, cacheEnable, FindFunc, FindLabel, getTokenValue, getVar, Static, AutoHotkeyMini, DynaCall, CriticalSection, CriticalObject, MemoryLoadLibrary, ResourceLoadLibrary, MemoryGetProcAddress, MemoryFreeLibrary, Other Changes
Example
AhkDll:=A_ScriptDir "\AutoHotkey.dll"
hModule:=DllCall("LoadLibrary","Str",AhkDll)
DllCall(AhkDll "\ahktextdll","Str","MsgBox from AutoHotkey.dll","Str","","Str","","Cdecl Uint")
MsgBox end
DllCall("FreeLibrary","UInt",hModule)
; COM Interface
;To use COM Interface, AutoHotkey.dll needs to be registered.
Run regsvr32.exe AutoHotkey.dll,%A_WorkingDir% ;register (make sure the path to AutoHotkey.dll is correct)
Run regsvr32.exe /u AutoHotkey.dll,%A_WorkingDir% ;unregister when not required anymore (not necessary if you want to use it all the time)
;Virtual Basic example.
Sub atest()
Dim ahk As Object
Set ahk = CreateObject("AutoHotkey.Script")
ahk.ahktextdll ("MsgBox Hello World!" & Chr(13) & "ExitApp")
End Sub
;Ahk example (Make sure AutoHotkey.dll is registered - Run regsvr32.exe AutoHotkey.dll,%A_WorkingDir%)
ahk:=ComObjCreate("AutoHotkey.Script")
ahk.ahktextdll("MsgBox Hello World!`nExitApp")
While ahk.ahkReady()
Sleep, 100
MsgBox Exiting now