These functions will make it easy to use AutoHotkey_H.dll/exe using AHK_L object syntax.
AHK_H v1 (AutoHotkey.dll and AutoHotkey.exe) can be downloaded here and AHK_H v2 here.
AhkExported is used to access main AutoHotkey_H.exe functions
AhkDllThread is used to access AutoHotkey.dll functions, it loads each dll from Memory and makes it possible to load the same dll as many times as you like.
Download:
AhkExported.ahk - or - AhkExported.ahk (v2 version)
AhkDllThread.ahk - or - AhkDllThread.ahk (v2 version)
!! PLEASE NOTE !!
;When compiled, AhkDllThread.ahk assumes AutoHotkey[Mini].dll is installed in executable, e.g.: If 0 FileInstall,AutoHotkey.dll,For AhkDllThread() we don't need to extract that file
Example requires and GlobalVarsScript and GlobalVarsScript
Thanks SKAN for FileGetVersionInfo_AW.
Save all files in your [url=http://www.autohotkey.com/docs/Functions.htm#lib]lib folder. (GlobalVarsScript.ahk + AhkExported.ahk + AhkDllThread.ahk)
AHK_H Example.
EXE:=AhkExported() DLL:=AhkDllObject("X:\AutoHotkey.dll") MEM:=AhkDllThread("X:\AutoHotkey.dll") GlobalVarsScript("EXE",0,EXE) GlobalVarsScript("DLL",0,DLL) GlobalVarsScript("MEM",0,MEM) DLL.ahktextdll("#Persistent`n" GlobalVarsScript()) MEM.ahktextdll("#Persistent`n" GlobalVarsScript()) DLL.ahkassign.var:="value" MEM.ahkassign.var:="anothervalue" EXE.ahkassign.var:="main" DLL.addscript("MEM.addscript(""ToolTip % EXE.ahkgetvar.var"",1)`nMsgBox % EXE.ahkfunction.func(1)",1) MsgBox % "Main and threads (var) values:" . "`n" EXE.ahkgetvar.var . "`n" DLL.ahkgetvar.var . "`n" MEM.ahkgetvar.var func(var){ Return "returned from main function" }
AHK_L example. (only AhkDllThread is compatible with AHK_L).
Loop 3 dll%A_Index%:=AhkDllThread(A_ScriptDir "\autohotkey.dll"),dll%A_Index%.ahkdll() dll1.ahkExec("CriticalObject:=CriticalObject()`nhObj:=CriticalObject(CriticalObject,1)`nhCriticalSection:=CriticalObject(CriticalObject,2)") dll2.ahkExec("CriticalObject:=CriticalObject(" (dll1.ahkgetvar.hObj+0) "," dll1.ahkgetvar.hCriticalSection ")") dll3.ahkExec("CriticalObject:=CriticalObject(" (dll1.ahkgetvar.hObj+0) "," dll1.ahkgetvar.hCriticalSection ")") dll1.addScript("Label:`nLoop 10000`nCriticalObject[A_Index]:=A_Index`nExitApp",1) dll2.addScript("Label:`nLoop 10000`nToolTip % CriticalObject[A_Index],50`nExitapp") dll3.addScript("Label:`nLoop 10000`nToolTip % CriticalObject[A_Index],100`nExitapp") dll1.ahkLabel("Label",1) Sleep 100 dll2.ahkLabel("Label",1) dll3.ahkLabel("Label",1) While % dll2.ahkReady() || dll3.ahkReady() Sleep 100 ExitApp Esc:=ExitApp