I am trying to use autohotkey.dll from AutoHotkey_H v1. I store the following script in an *.ahk file and run it (using the installed Autohotkey_L):
Code: Select all
;---------------- Launcher for Script1 and Script2 ----------------
#SingleInstance,Ignore
#Persistent
Menu,tray,add,Launch Script1,txtScript1
Menu,tray,add,Launch Script2,txtScript2
Menu,tray,add,Exit launcher,Exitlauncher
hModule:=DllCall("LoadLibrary","Str",AhkDllPath:=(launcherDir:=A_ScriptDir) "\dll\AutoHotkey.dll")
return
Exitlauncher:
ExitApp
;--------------- Script1 ----------------
txtScript1:
vtxtScript=
(% `
#Persistent
Menu,Tray,Icon,% StrReplace(A_Args[1],"""") "\Icons\GplusOrange.ico"
Menu,tray,add,Show some message scr1,msg
Menu,tray,add,Exit Script1,ExitScript
return
msg:
MsgBox,% "Some message scr1`nA_Args[1]=launcherDir: " A_Args[1] "`nA_Args[2]=hModule: " A_Args[2]
return
ExitScript:
MsgBox, % "Exiting Script1"
ExitApp
)
hThread1:=DllCall(AhkDllPath "\ahktextdll","Str",vtxtScript,"Str","Title Script1","Str","""" launcherDir """ " hModule,"Cdecl UPTR")
return
;--------------- Script2 ----------------
txtScript2:
vtxtScript=
(% `
#Persistent
Menu,Tray,Icon,% StrReplace(A_Args[1],"""") "\Icons\GplusOrange.ico"
Menu,tray,add,Show some message scr2,msg
Menu,tray,add,Exit Script2,ExitScript
return
msg:
MsgBox,% "Some message scr2`nA_Args[1]=launcherDir: " A_Args[1] "`nA_Args[2]=hModule: " A_Args[2]
return
ExitScript:
MsgBox, % "Exiting Script2"
ExitApp
)
hThread2:=DllCall(AhkDllPath "\ahktextdll","Str",vtxtScript,"Str","Title Script2","Str","""" launcherDir """ " hModule,"Cdecl UPTR")
return
---------------------------
AutoHotkey
---------------------------
Error: CONTINUABLE EXCEPTION_ACCESS_VIOLATION
Mouse and Keyboard hooks have been disabled.
- Press yes to exit thread and continue execution.
- Press no to continue thread (debug).
- Press cancel to exit application.
Exception was caused in thread id: 10176
Line: 2
LineFile: #Persistent
Menu,Tray,Icon,% StrReplace(A_Args[1],"""") "\Icons\GplusOrange.ico"
Menu,tray,add,Show some message scr1,msg
Menu,tray,add,Exit Script1,ExitScript
return
msg:
MsgBox,% "Some message scr1`nA_Args[1]=launcherDir: " A_Args[1] "`nA_Args[2]=hModule: "
---------------------------
Yes No Cancel
---------------------------
What am I doing wrong?