Hotstring trigger string ending with backtick in v2 Topic is solved

Report problems with documented functionality
LaszloH
Posts: 21
Joined: 21 Oct 2023, 12:23

Hotstring trigger string ending with backtick in v2

21 Oct 2023, 12:50

A traditional hotstring cannot be defined if its trigger string ends with a backtick, like
::a``::b
AutoHotkey 2.0.10 only pops up a very unhelpful message box, telling that I seem to want to use AutoHotkey 1. No information about where and what the problem was in the script.

It works if the backtick is not the last character in the trigger string.
Also, the Hotstring command works with a trailing backtick. Only the traditional form brings up the dreaded "It looks like the script you are trying to run requires AutoHotkey v1..."
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: Hotstring trigger string ending with backtick in v2

21 Oct 2023, 13:22

I don't get any error message for:

Code: Select all

::a``::b
This hotstring works for me as expected in AHK v2.0.10 (like in v1) - both on german layout (there, ` is a dead key) and US layout (normal key).

Is there perhaps something else in your script which causes the problem? Is this the actual code you are trying to run?
LaszloH
Posts: 21
Joined: 21 Oct 2023, 12:23

Re: Hotstring trigger string ending with backtick in v2

21 Oct 2023, 13:50

The script contains this single line. Windows 11, American English version. The script is edited in Notepad, and saved in UTF-8 format.
LaszloH
Posts: 21
Joined: 21 Oct 2023, 12:23

Re: Hotstring trigger string ending with backtick in v2

23 Oct 2023, 00:54

There is another ugly workaround (besides using the HotString command):
::a``:::{BS}b
It looks like the parser treats the second backtick as escaping the colon, but the interpreter treats the two backticks as one literal backtick. The replacement string is then ":b", so a backspace is needed to remove the extra colon. It is also possible that the executable was compiled with such local settings, where the backtick is treated as a modifier key, but it looks unlikely.
lexikos
Posts: 9780
Joined: 30 Sep 2013, 04:07
Contact:

Re: Hotstring trigger string ending with backtick in v2

23 Oct 2023, 02:53

AutoHotkey 2.0.10 only pops up a very unhelpful message box, telling that I seem to want to use AutoHotkey 1.
That isn't AutoHotkey 2.0.10. That is the AutoHotkey Launcher (UX\launcher.ahk). The launcher is a separate process which decides which interpreter to execute the script with (there can be any number of versions installed, 32-bit or 64-bit, etc.). Your script triggers a false positive of the rule that naked escape characters aren't valid in expressions in v2 (e.g. Send `` would be valid only in v1). You can circumvent it by adding #Requires AutoHotkey v2 to your script.
It looks like the parser treats the second backtick as escaping the colon, but the interpreter treats the two backticks as one literal backtick.
Not "the parser", just a complicated regex pattern used by the launcher.
LaszloH
Posts: 21
Joined: 21 Oct 2023, 12:23

Re: Hotstring trigger string ending with backtick in v2  Topic is solved

23 Oct 2023, 11:33

Thanks, lexicos. Adding #Requires AutoHotkey v2 to the script indeed hides this launcher problem.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 30 guests