Calling Hotstring in Command mode

Discussion, questions and support.
Post Reply
Marty123
Posts: 11
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » May 11th, ’22, 13:38

Hi guys, not sure if this was brought up before, but I can't seem to find literature nor documentation on this, (that or i'm just plain dumb) nor AHK forums about what is seemingly, a straight-forward problem.

I have a hotstring with replaces addr1 (abbrev) with my address (i.e, 99, Sesame Street, 01-01). The entry in the phrase file will look like
::addr1::99, Sesame Street, 01-01

When i put in some simple code under 'command' mode, i would like the flexibility to use hotstring such as addr1 for either output purposes or as a variable for another set of codes that i write, depending on what i want eventually. I understand there is a feature of using 'insert another item' under 'send' mode, but i felt learning to be comfortable using command mode matters more, as it is the same language as ahk, and i can find more utility in learning to write that way, than to rely solely on the send and run function. Also there is a vast community in ahk universe. Alas, the above have been gnawing at me for a couple days now, so i would appreciate any help
User avatar
Tom
Posts: 611
Joined: Nov 24th, ’15, 23:39

Post by Tom » May 12th, ’22, 18:56

Yes, this is possible by using gosub:

Code: Select all

gosub ::addr1
Marty123
Posts: 11
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » May 13th, ’22, 03:45

Tom wrote:
May 12th, ’22, 18:56
Yes, this is possible by using gosub:

Code: Select all

gosub ::addr1
Thank you for your reply, Tom. When i tried to use gosub this way, ( i am creating a outlook mail and using said hotstring) i faced an error, understandably as it is within the encased quotes. I left the erroneous code unchanged. How do I use gosub in this context?

Code: Select all

FilePath:= A_Desktop "\lodgedocument.pdf"
if not FileExist(FilePath)
	msgbox % FilePath "`nDOES NOT EXIST"
else
{
	oOutlook:=ComObjCreate("Outlook.Application").CreateItem(0)
	oOutlook.Subject:= “Mail to gosub ::addr1”
	oOutlook.To:="[email protected]"
              oOutlook.Cc:="[email protected]"
	oOutlook.Body:="Dear Colleagues, ..."
	oOutlook.Attachments.Add(FilePath)
	oOutlook.Display
}
return 
Marty123
Posts: 11
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » May 13th, ’22, 04:14

also, Tom, what about triggering shortcuts using gosub?

say Ctrlkey + Altkey + P types out [99,sesame street]

what do i put after the gosub command? gosub ::^!p ? (logically speaking)
for that matter, i went to the folders and tried to find the back up files for my shortcuts, just as i did for my phrase file, but i can't find anything i can reference to, like I am able to do so for my phrase file, hence i knew it was ::addr1::99, Sesame Street, 01-01

once again, thanks Tom, in advance.
User avatar
Tom
Posts: 611
Joined: Nov 24th, ’15, 23:39

Post by Tom » May 16th, ’22, 16:35

Marty123 wrote:
May 13th, ’22, 03:45

Thank you for your reply, Tom. When i tried to use gosub this way, ( i am creating a outlook mail and using said hotstring) i faced an error, understandably as it is within the encased quotes. I left the erroneous code unchanged. How do I use gosub in this context?
You cannot use it that way. Gosub will execute the addr1 and return, it needs to be in a separate line.

You can execute a shortcut in a similar way:

Code: Select all

gosub ^!p
See: https://www.autohotkey.com/docs/Hotkeys.htm

For the location of the backup, check Preferences/Folders/Backup - the default is AppData/FastKeys.
Marty123
Posts: 11
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » May 22nd, ’22, 03:59

Dear Tom, thanks so much, it helps!
Post Reply