Page 1 of 1

Error while Including Autohotkey.dll

Posted: 11 Mar 2018, 16:13
by Renz
Hey :)

if i include the Autohotkey.dll with #Include, i get this error...

The Script:

Code: Select all

#Persistent
#SingleInstance force
#include %A_MyDocuments%\AutoHotkey\Lib\AutoHotkey.dll
The Error:

Code: Select all

---------------------------
test.ahk
---------------------------
Error at line 1 in #include file "C:\Users\...\Documents\AutoHotkey\Lib\AutoHotkey.dll".

Line Text: MZ
Error: This line does not contain a recognized action.

The program will exit.
---------------------------
OK   
---------------------------
anyone has an idea?
What it mean?

Re: Error while Including Autohotkey.dll

Posted: 11 Mar 2018, 16:21
by HotKeyIt
You can't include a dll, best is to use AHK_H with AutoHotkey.dll and AhkThread to launch a new thread.

Otherwise you will need to call DllCall("LoadLibrary","Str",PathToAutoHotkeyDLL,"Ptr"), and then start a thread using ahkdll or ahktextdll, see docs.

Re: Error while Including Autohotkey.dll

Posted: 11 Mar 2018, 16:37
by Renz
Oh ok was wondering about that in the doc is written...
dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module.
DllCall(dllpath "\ahktextdll","Str","","Str","","CDecl") ; start a new thread, just the function.
DllCall(dllpath "\ahkExec","Str","MsgBox Hello World!","CDecl") ; add and execute code

; Same example like above but using included AutoHotkey.dll
dll:=AhkThread()
dll.ahkExec["MsgBox Hello World!"]

; Execute code in current thread
ahkExec("MsgBox Test")
The ; Same example like above but using included AutoHotkey.dll confusing me, Was a misstaken from me, sry about that...

But thank you for the fast answer :)