Page 1 of 1

How to get characters typed in last hotstring?

Posted: 29 Nov 2022, 19:53
by poetofpiano
I am a heavy user of hotstrings, and one thing that would be useful to me is know what characters I typed that were auto-deleted and then expanded. I know that the variable A_PriorHotkey will contain the name of the last hotkey I typed, e.g., ::btw::, but if I for example typed "BTW", that variable will not capture that I typed all uppercase letters.

I don’t see that what I want is available in the hotstring function, but I figured I’d ask in case I’m missing something.

Re: How to get characters typed in last hotstring?  Topic is solved

Posted: 29 Nov 2022, 20:50
by mikeyww

Code: Select all

:C:btw::
:C:BTW::
keys := RegExReplace(A_ThisHotkey, "^:.*?:")
MsgBox, %keys%
Return

Re: How to get characters typed in last hotstring?

Posted: 29 Nov 2022, 21:23
by poetofpiano
Thank you for the reply. I am most interested in somehow duplicating a functionality in PhraseExpress where, after completing a word, you can backspace back into the completed word and edit it without triggering another hotstring when you next press space. Say I have the following hotstrings defined:

Code: Select all

::e::early
:appe::apple
If I were to type "app" and press space, then press backspace and type "e" and then space, it would be cool if it expanded into "apple" instead of "early." I often have these unwanted expansions in my day to day typing. But I refuse to continue using PhraseExpress; it’s impossible to export your data in a usable fashion.

Re: How to get characters typed in last hotstring?

Posted: 29 Nov 2022, 22:34
by mikeyww
It already does that, but you need a valid script.

Code: Select all

::e::early
::appe::apple
Explained: Hotstrings
To define a hotstring, enclose the triggering abbreviation between pairs of colons.

Re: How to get characters typed in last hotstring?

Posted: 30 Nov 2022, 10:15
by poetofpiano
You’re right, I gave a bad example. Here is what I meant to illustrate:

Code: Select all

::e::early
::app::app
::appe::apple
Now if I follow the steps I outlined above, I will get the unwanted behavior I described, where I get an expansion of the ::e:: hotstring when I was actually trying to expand ::appe::. This is because the middle expansion, ::app::, already cleared the hotstring recognizer when it expanded following a space ending character.

Re: How to get characters typed in last hotstring?

Posted: 30 Nov 2022, 10:20
by mikeyww
Why would you have the following hotstring?

Code: Select all

::app::app

Re: How to get characters typed in last hotstring?

Posted: 01 Dec 2022, 17:27
by poetofpiano
I certainly wouldn’t, but I have had this experience with hotstrings that I do logically use.

Re: How to get characters typed in last hotstring?

Posted: 01 Dec 2022, 17:32
by mikeyww
An example would be useful.