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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
poetofpiano
Posts: 61
Joined: 25 Jan 2016, 14:26

How to get characters typed in last hotstring?

Post by poetofpiano » 29 Nov 2022, 19:53

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.

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

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

Post by mikeyww » 29 Nov 2022, 20:50

Code: Select all

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

poetofpiano
Posts: 61
Joined: 25 Jan 2016, 14:26

Re: How to get characters typed in last hotstring?

Post by poetofpiano » 29 Nov 2022, 21:23

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.

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: How to get characters typed in last hotstring?

Post by mikeyww » 29 Nov 2022, 22:34

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.

poetofpiano
Posts: 61
Joined: 25 Jan 2016, 14:26

Re: How to get characters typed in last hotstring?

Post by poetofpiano » 30 Nov 2022, 10:15

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.

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: How to get characters typed in last hotstring?

Post by mikeyww » 30 Nov 2022, 10:20

Why would you have the following hotstring?

Code: Select all

::app::app

poetofpiano
Posts: 61
Joined: 25 Jan 2016, 14:26

Re: How to get characters typed in last hotstring?

Post by poetofpiano » 01 Dec 2022, 17:27

I certainly wouldn’t, but I have had this experience with hotstrings that I do logically use.

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: How to get characters typed in last hotstring?

Post by mikeyww » 01 Dec 2022, 17:32

An example would be useful.

Post Reply

Return to “Ask for Help (v1)”