AutoHotkey.dll or AutoHotkey.Interop with CLR

Ask for help, how to use AHK_H, etc.
burque505
Posts: 1732
Joined: 22 Jan 2017, 19:37

AutoHotkey.dll or AutoHotkey.Interop with CLR

27 May 2018, 18:29

Hi all,
I'm look for some tips on how to get AutoHotkey.dll and/or AutoHotkey.Interop to work.
I've been able get the following code to run in LinqPad by adding a reference to AutoHotkey.Interop:

Code: Select all

Dim Engine As New AutoHotkey.Interop.AutoHotkeyEngine
engine.ExecRaw("#InstallKeybdHook")
engine.ExecRaw("!^g::send Hello World")
engine.ExecRaw("msgbox, Move me out of the way`nI block threads")
However, if I try it in AHK script, like so (CLR_H.ahk is just CLR.ahk with references to built-in variables renamed - "null", that is, renamed to "nulo" - works fine if I'm not trying to call AutoHotkey.Interop or AutoHotkey.dll):

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
;~ SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;~ SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#Include CLR_H.ahk

vb =
(
	Imports System.IO
	Imports System.Runtime
	Imports System.Windows.Forms
	Imports AutoHotkey.Interop
    Class Foo
	Sub Test()
	Dim Engine As New AutoHotkey.Interop.AutoHotkeyEngine
		engine.ExecRaw("#InstallKeybdHook")
		engine.ExecRaw("!^g::send Hello World")
		engine.ExecRaw("msgbox, Move me out of the way`nI block threads")
    End Class
)
asm := CLR_CompileVB(vb, "System.dll | System.IO.dll | System.Windows.Forms.dll")
obj := CLR_CreateObject(asm, "Foo")

obj.Test()
I get the following error:
Spoiler
All help greatly appreciated!
Regards,
burque505

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 18 guests