basic text replacement Topic is solved
basic text replacement
Hi,
I am merely trying to use AHK for basic text replacement.
All was fine, I have a trigger key of hash (#) for example.....
#a would generate my address
#e my email address
etc. etc. Anyway, I now wished to generate: Please Enter Code #123 .... where the last 3 digits will vary
My Replacement line is :*:#u:: Please Enter Code #123 . However, what comes out is Please Enter Code 123
- the # is missing.
How may I get round this (I don't want to change the trigger from a #)
Grateful for any suggestions - many thanks.
Geoff H.
I am merely trying to use AHK for basic text replacement.
All was fine, I have a trigger key of hash (#) for example.....
#a would generate my address
#e my email address
etc. etc. Anyway, I now wished to generate: Please Enter Code #123 .... where the last 3 digits will vary
My Replacement line is :*:#u:: Please Enter Code #123 . However, what comes out is Please Enter Code 123
- the # is missing.
How may I get round this (I don't want to change the trigger from a #)
Grateful for any suggestions - many thanks.
Geoff H.
Last edited by gregster on 08 Aug 2022, 11:49, edited 1 time in total.
Reason: Added provisional topic name. Feel free to change it to something more appropriate.
Reason: Added provisional topic name. Feel free to change it to something more appropriate.
Re: basic text replacement
Try:
You have to send the data in raw mode or else the #1 is interpreted as WinKey-1.
Russ
Code: Select all
:*R:#u::Please enter Code #123
Russ
Re: basic text replacement
Russ, many thanks for a speedy reply.
I looked up "Raw mode" but couldn't see what I was to do in a text file, i.e. do you know what I should have entered into my text file, instead of....
:*R:#u::Please enter Code #123
..... in order to get the desired effect?
Thanks once again.
Best Regards.
Geoff H.
I looked up "Raw mode" but couldn't see what I was to do in a text file, i.e. do you know what I should have entered into my text file, instead of....
:*R:#u::Please enter Code #123
..... in order to get the desired effect?
Thanks once again.
Best Regards.
Geoff H.
Re: basic text replacement
Hi again Russ,
Further to my last message, I have been "playing about" with AHK and find I can get the desired effect by using brackets, i.e.
Instead of.....
:*:#u::Please enter Code: #123
I enter this....
:*:#u::
(
Please enter Code: #123
)
..... which works a treat.
Again, thanks very much for your help & support, it would have taken me MUCH longer to get there without your response
Best Regards.
Geoff H.
Further to my last message, I have been "playing about" with AHK and find I can get the desired effect by using brackets, i.e.
Instead of.....
:*:#u::Please enter Code: #123
I enter this....
:*:#u::
(
Please enter Code: #123
)
..... which works a treat.
Again, thanks very much for your help & support, it would have taken me MUCH longer to get there without your response
Best Regards.
Geoff H.
Re: basic text replacement
When you want the characters "Please enter Code #123" in your text, simply type #u. That's the actual # character - NOT the Win key. The "R" in the definition means that the "#" in your replacement string will be typed instead of interpreted as the Win key. When I tried your original code, AHK was sending Win-1 to Windows which activates the first window in the stack of open windows. The "R" prevents that.geoffh wrote: I looked up "Raw mode" but couldn't see what I was to do in a text file, i.e. do you know what I should have entered into my text file, instead of....
:*R:#u::Please enter Code #123
..... in order to get the desired effect?
If it works, great, but is unnecessary. Since it is the last hotstring definition, the "Return" is implied, but if you add a definition after that one, you must put a "Return" after that definition, i.e.geoffh wrote: I enter this....
:*:#u::
(
Please enter Code: #123
)
..... which works a treat.
Code: Select all
:*:#u::
(
Please enter Code: #123
)
Return
Re: basic text replacement
Yep, # is my trigger key, I have about a dozen "Text Replacements" set up.
However, going back to my example above, where I wanted to generate a "#", it did not work with
:*:#u::Please enter Code: #123
for exactly the reason you said.
When I modified it to
:*:#u::
(
Please enter Code: #123
)
- it worked, due to anything within the brackets being taken "as is".... the brackets themselves do not get displayed.
One other thing to mention, I have several other rows in my text file (which I Compile) following the "u" entry, WITHOUT any "Return" - but these all work fine.
Hope this helps others.
Best Regards.
Geoff H.
However, going back to my example above, where I wanted to generate a "#", it did not work with
:*:#u::Please enter Code: #123
for exactly the reason you said.
When I modified it to
:*:#u::
(
Please enter Code: #123
)
- it worked, due to anything within the brackets being taken "as is".... the brackets themselves do not get displayed.
One other thing to mention, I have several other rows in my text file (which I Compile) following the "u" entry, WITHOUT any "Return" - but these all work fine.
Hope this helps others.
Best Regards.
Geoff H.
Re: basic text replacement
Did you try my code below? It worked perfectly for me.
Russ
Code: Select all
:*R:#u::Please enter Code #123
Re: basic text replacement
BIG apologies, Russ... I hadn't spotted the "R" at the beginning of the Line : o - presumably the R indicates Raw?
Do you have/could you provide a link to the part of the AHK Documentation where that sits please (I failed miserably looking for this!!)
Do you have/could you provide a link to the part of the AHK Documentation where that sits please (I failed miserably looking for this!!)
Re: basic text replacement Topic is solved
No worries. You can find it here under Hotstrings/Options.
BTW, I just happened to notice while I was looking it up, that the option "T" (Text mode) in place of "R" (Raw mode) may be more reliable. I didn't see this before. Try both. Your mileage may vary.
Either one should work:
Russ
BTW, I just happened to notice while I was looking it up, that the option "T" (Text mode) in place of "R" (Raw mode) may be more reliable. I didn't see this before. Try both. Your mileage may vary.
Either one should work:
Code: Select all
:*R:#u::Please enter Code #123
; or
:*T:#u::Please enter Code #123
Re: basic text replacement
Once again, many many thanks - great stuff, REALLY helped.....