I'm finding that % symbols seem to always seem to get interpreted literally, instead of dereferencing a variable. Tried any variation of concatenating and using expressions with same result.
using sharpAHK;
[...]
_AHK ahk = new _AHK();
ahk.Execute(@"
x:=""hello""
MsgBox ""x is "". %x%
");
produces:

I found two workarounds though!
- If I change the dereferencing character to something else, like
$, then it works as expected
#
_AHK ahk = new _AHK();
ahk.Execute(@"
#DerefChar $
x:=""hello""
MsgBox ""x is "". $x$
";

- Instead of initializing using
new _AHK(), use the ahkGlobal.ahkdll.ExecRaw()
ahkGlobal.ahkdll = new AutoHotkey.Interop.AutoHotkeyEngine();
ahkGlobal.ahkdll.ExecRaw(@"
x:=""hello""
MsgBox ""x is "". %x%
");
It must be something to do with escaping chars somewhere along the line between the C# verbatim string and the string that the dll executes, but i really have no idea... hope this helps someone though.
I'm not sure which workaround is more desirable. The documentation (https://www.autohotkey.com/docs/commands/_EscapeChar.htm#Related) does warn against using #DerefChar because it "does more harm than good" and won't be supported in V2
I'm finding that % symbols seem to always seem to get interpreted literally, instead of dereferencing a variable. Tried any variation of concatenating and using expressions with same result.
produces:

I found two workarounds though!
$, then it works as expectednew _AHK(), use theahkGlobal.ahkdll.ExecRaw()It must be something to do with escaping chars somewhere along the line between the C# verbatim string and the string that the dll executes, but i really have no idea... hope this helps someone though.
I'm not sure which workaround is more desirable. The documentation (https://www.autohotkey.com/docs/commands/_EscapeChar.htm#Related) does warn against using
#DerefCharbecause it "does more harm than good" and won't be supported in V2