-
Notifications
You must be signed in to change notification settings - Fork 8
unable to dereference % in Execute() method #4
Copy link
Copy link
Open
Description
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%
");
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 theahkGlobal.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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels