using special characters Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vjlantergmailcom
Posts: 5
Joined: 06 Feb 2023, 14:00

using special characters

Post by vjlantergmailcom » 07 Feb 2023, 00:01

The following code is just me trying to get around a problem. If I type the letters b and d I get BadDad13. What I need is BadDad13#1 to be returned. I get the error;

Error: Illegal character in expression.

Text: #1)
Line: 1


Code: Select all

RunAs Administrator, BadDad13`#1
#SingleInstance Force
::bd::BadDad13`#1
return

gregster
Posts: 8999
Joined: 30 Sep 2013, 06:48

Re: using special characters  Topic is solved

Post by gregster » 07 Feb 2023, 02:34

`# is not listed among the allowed escape sequences: https://www.autohotkey.com/docs/v2/misc/EscapeChar.htm
For hotstrings (or Send), use either text mode or braces:

Code: Select all

:T:bd::BadDad13#1

Code: Select all

::bd::BadDad13{#}1
Edit:
Your error message seems to indicate that you are using AHK v2. which has some syntax differences compared to AHK v1. Then, I would try:

Code: Select all

RunAs "Administrator", "BadDad13#1"
#SingleInstance Force
:T:bd::BadDad13#1
Compare RunAs (v2). But it doesn't make much sense without following Run or RunWait - which I don't see in the snippet, though it could be in your actual code. So is it really what you want?
Or rather run the script as admin (https://www.autohotkey.com/docs/v2/lib/Run.htm#RunAs) ?

vjlantergmailcom
Posts: 5
Joined: 06 Feb 2023, 14:00

Re: using special characters

Post by vjlantergmailcom » 07 Feb 2023, 14:52

I didn't want to leave this topic hanging on my response. The following code did the trick for special characters;

:T:bd::BadDad13#1


I'm still working on the difference between v1 and v2. I need to just pay attention to v2 syntax.

Post Reply

Return to “Ask for Help (v1)”