Variable Inside a Hotstring Doesn't 'Expand' on Output. How to Get it to Do So? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Buddha Nature
Posts: 34
Joined: 13 Feb 2022, 06:42

Variable Inside a Hotstring Doesn't 'Expand' on Output. How to Get it to Do So?

Post by Buddha Nature » 24 Dec 2022, 11:58

I have following code:

Code: Select all

FormatTime, CurrentDate,, dddd`, dd MMMM yyyy
:*:hc address::Test Address`r10/28 Elm Street`rEdinburgh`rMid Lothian`rEH12 5EL`r`r%CurrentDate%`r`r
It is meant to auto-type an address and then the current date. However, if I run it I get the following output:
Test Address
10/28 Elm Street
Edinburgh
Mid Lothian
EH12 5EL

%CurrentDate%
Obviously this isn't what I want to happen. I have been trying to get this work for an hour now, without success. What am I doing wrong? How do I get to properly type the proper date?

P.S. If it is possible I want the entire hotstring to be a single line — as show above (my intention).

User avatar
boiler
Posts: 17399
Joined: 21 Dec 2014, 02:44

Re: Variable Inside a Hotstring Doesn't 'Expand' on Output. How to Get it to Do So?  Topic is solved

Post by boiler » 24 Dec 2022, 12:06

Use Send, which you can put on the next line so it executes the command rather than just sending it as text:

Code: Select all

FormatTime, CurrentDate,, dddd`, dd MMMM yyyy
:*:hc address::
Send, Test Address`r10/28 Elm Street`rEdinburgh`rMid Lothian`rEH12 5EL`r`r%CurrentDate%`r`r
return

Or using the X option:

Code: Select all

FormatTime, CurrentDate,, dddd`, dd MMMM yyyy
:*X:hc address::Send, Test Address`r10/28 Elm Street`rEdinburgh`rMid Lothian`rEH12 5EL`r`r%CurrentDate%`r`r

User avatar
Buddha Nature
Posts: 34
Joined: 13 Feb 2022, 06:42

Re: Variable Inside a Hotstring Doesn't 'Expand' on Output. How to Get it to Do So?

Post by Buddha Nature » 24 Dec 2022, 12:18

Thank you so very, very much Boiler. Went with the 'X' option and it works just fine. Will go and do some research on both the options you pointed to. Thanks again! :D

Post Reply

Return to “Ask for Help (v1)”