Trigger Hotkey Text Expansion on Send

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
]MR[
Posts: 1
Joined: 12 Jan 2019, 19:37

Trigger Hotkey Text Expansion on Send

12 Jan 2019, 21:09

Forgive me if I'm missing something obvious, I'm a step up from an AutoHotKey beginner and have searched everywhere for an answer. Maybe I don't know the proper terminology, but here is what I would like to do:

I have to often reference documents from a list of several dozen and have successfully made hotstrings to call them up. For example:

Code: Select all

;Document List Hotstrings
::abc0101::ABC-01.01 Title One
::abc0202::ABC-01.02 Title Two
::def0101::DEF-01.01 Title Three
::def0102::DEF-01.02 Title Four
Works like a charm. However, I would like to be able to enclose the title of the document in double brackets on occasion. What I would like to do is to be able to type the basic hotstring to get the unbracketed title in some cases, and in others add a bracket at the beginning of the hotstring to have it trigger the double brackets to enclose the title. What that looks like is something like:

abc0101 > ABC-01.01 Title One
[abc0101 > [[ABC-01.01 Title One]]

Now, I could duplicate all the hotstrings and make two versions, one with brackets, one without, but what I would really like to do is something like below; which would read my hotstring, decide if there is a leading "[" and then choose whether or not to enclose the title based on that.

The problem is, SendInput only sends the hotstring and it doesn't trigger the text expansion. I end up with something like [[abc0101]] instead of [[ABC-01.01 Title One]]. Is it even a possibility to do what I want to do, or is there a better way to do this? I feel like I'm missing some simple thing, but I can't find anything addressing this.

Here is my _not working_ vision of what the code should look like (which would be paired with the document hostring list, of course):

Code: Select all

#k::
Input, UserInput, L8, {enter}
FirstChar := SubStr(UserInput, 1, 1) ; What is the first character of the UserInput?
if (FirstChar = "[") 
{
Chop := SubStr(UserInput, 2) ;remove the leading bracket
SendInput, [[%Chop%]] ;enclose the title in brackets
} else {
SendInput, %UserInput% ;otherwise send the title without brackets
}
return

As I said, the text doesn't expand and leaves me with the hotstring, not the full title of the document.

Thank you for any help you can provide.

MR

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], KenC80, Proxima and 287 guests