How to declare a variable in hotstring in AutoHotKey?

I am trying to create a script that takes a name and adds it to a pre-written block of text.

Essentially, I want to write "emailDave" and have the name Dave inserted in a line of text, which is then sent. I just don't know how to change the hotline this way.

I am currently using a method that requests a name using an InputBox and inserts it into the text. This works fine on the desktop, but I am using Windows 8 and for some terrible reason, the InputBox will not display in the application (i.e. outside the operating mode).

I know that there must be a way to use the text that I entered "email vs emailDave" to affect the variable, instead of taking me on this geese hunt with the InputBox.

However, if anyone knows a workaround for displaying InputBox in Windows 8 applications (especially Mail), this would be more than useful.

The current script that works fine on the desktop but does not work in the application:

::email:: InputBox, thename, Enter the name, What is the name SendInput Hi %thename%,{enter}{enter}Sample text.{enter}{enter}Thanks,{enter}Zach Return 

Is there a way to do something like this work?

 ::email{%thename%}:: SendInput Hi %thename%,{enter}{enter}Sample text.{enter}{enter}Thanks,{enter}Zach Return 
+4
source share
3 answers

How about him:

 :?*:email:: Input, thename, v,{Enter}{Space} If (thename = "") { SendInput, {Bs}email ` Return } StringLen,MyLen, thename MyLen++ SendInput {BackSpace %MyLen%}Hi +%thename%,{Enter 2}Sample text.{Enter 2}Thanks,{Enter}Zach Return 

By adding + before the name string, the first letter will be capitalized.

Input: "emailrobert {Enter}" or "emailRobert {Enter}" both give:

Hi Robert,

Sample text.

Thanks,
Zach

and the email address {Space} will send the email address {Space}.

0
source

If you really want to avoid using InputBox, I have a more complicated solution for you. You can use a library called RegEx Powered Dynamic HotStrings .

Save the file from this link to the lib folder inside the folder containing AutoHotkey.exe (create if necessary).

In this example, enter emailJohn and then Space .

 #Include lib\DynamicHotstrings.ahk hotstrings("email(\w+)\s", "email") Return email: SendInput, Hi %$1%,{Enter 2}Sample text.{Enter 2}Thanks,{Enter}Zach return 
+1
source
 ::email:: inputbox, name msgbox, %name% return 

take "dave" from the hotline

after testing, replace msgbox,% name% with any string sent.

0
source

All Articles