I'm try include AutoHotkey.dll in my C# project. I'm using AutoHotkey.Interop https://github.com/amazing-andrew/AutoHotkey.Interop, but my Autohotkey.dll was compiled by me and I would like to know where I change the dlls.
I'm trying to run the LoadFile ahk.LoadFile("test.ahk"); with the code below. The AhkThread.ahk file is in the correct folder and works when I open test.ahk outside of Visual Studio.
I already changed all AutoHotkey.dll in the AutoHotkey.Interop folder by my compiled AutoHotkey.dll and even then the error continues.
Code: Select all
; FILE Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AutoHotkey.Interop;
namespace ahk
{
class Program
{
static void Main(string[] args)
{
//grab a copy of the AutoHotkey singleton instance
var ahk = AutoHotkeyEngine.Instance;
//Load a library or exec scripts in a file
ahk.LoadFile("test.ahk");
}
}
}
Code: Select all
; FILE test.ahk
#NoTrayIcon
#SingleInstance, Force
share:=CriticalObject({count:0,s1Thread:"",s2Thread:""})
s1Script := "
(
#NoTrayIcon
share:=CriticalObject(" (&share) ")
Loop,
{
Count := ++share.count
ToolTip, s1 count: `%Count`%
}
)"
s2Script := "
(
#NoTrayIcon
share:=CriticalObject(" (&share) ")
Loop,
{
if share.s1Thread.ahkReady() {
Count := share.count
MsgBox, Count s1: `%Count`%
} else {
MsgBox, Count s1: STOPPED
}
}
)"
Gui, Add, Checkbox, h50 w400 vs1 gs1G, START COUNT WITH s1
Gui, Add, Button, h50 w400 vs2 gs2G, CHECK s1 WITH s2
Gui, Show, `t
return
;s1
;===============
s1G:
if (toggles1 := !toggles1) {
if !share.s1Thread.ahkReady() {
SoundBeep, 4000
share.s1Thread := AhkThread(s1Script)
}
} else {
if share.s1Thread.ahkReady() {
SoundBeep, 8000
share.s1Thread.ahkTerminate()
}
share.count:=0
}
return
;s2
;===============
s2G:
if (toggles2 := !toggles2) {
GuiControl, , s2, STOP CHECK s1 WITH s2
if !share.s2Thread.ahkReady() {
SoundBeep, 4000
share.s2Thread := AhkThread(s2Script)
}
} else {
if share.s2Thread.ahkReady() {
SoundBeep, 8000
share.s2Thread.ahkTerminate()
}
GuiControl,, s2, CHECK s1 WITH s2
}
return
GuiClose:
if share.s1Thread.ahkReady() {
SoundBeep, 8000
share.s1Thread.ahkTerminate()
}
if share.s2Thread.ahkReady() {
SoundBeep, 8000
share.s2Thread.ahkTerminate()
}
ExitApp
Error: