AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Email Templates - Can I use variables?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
djmundy



Joined: 18 Mar 2010
Posts: 3

PostPosted: Thu Mar 18, 2010 2:23 am    Post subject: Email Templates - Can I use variables? Reply with quote

Hi,

Currently I have a hotkey where I type -status and it types in an email for me. Eg:

::-status::
Send Hi, please update the status of this ticket

I'd like to be able to type something like -status:John and for it to type "Hi John, please update" etc.

But I don't want to hard code every name into the script, as there are hundreds, and I'd like to be able to easily update the content of the email from time to time.

Is this possible?

Thanks and regards,
Daniel Mundy
Back to top
View user's profile Send private message
poo_noo



Joined: 08 Dec 2006
Posts: 248
Location: Sydney Australia

PostPosted: Thu Mar 18, 2010 2:45 am    Post subject: Reply with quote

maybe use an inputbox ??

Code:
::-status::
InputBox, thename, Enter the name, What is the name, hide
Send Hi %thename%, please update the status of this ticket
Return

_________________
Paul O
Back to top
View user's profile Send private message Visit poster's website
djmundy



Joined: 18 Mar 2010
Posts: 3

PostPosted: Thu Mar 18, 2010 3:02 am    Post subject: Reply with quote

Hi poo_noo,

Thanks for your reply. That looks like a step in the right direction! It works as it should, but I have a lot of text for this email and my script actually looks like this:

; Respond to new ticket
::-respond::
{
InputBox, thename, Enter the name, What is the name, hide
(
Hi %thename%,
How are you?
)
Return
}

Sorry about the confusion I have caused, I tried to simplify my example script a little too much!

I did read that the brackets are a continuation section causes the hotstring to default to raw more, and I think this is my problem, but I would have thought it would at least type %thename% without substituting the variable... but it doesn't type anything.

Do you know how to make this work with a continuation section?

Thanks again,
Daniel Mundy
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Mar 18, 2010 3:19 am    Post subject: Re: Email Templates - Can I use variables? Reply with quote

Another approach...

Code:
:b0:-status::
A_ThisHotstringName:=RegExReplace(A_ThisHotkey, "^:.*:")
Input, input, v, {Enter}{Escape}
if (errorlevel="EndKey:Enter") {
   name:=input!="" ? " " input:""
   bslen:=StrLen(A_ThisHotstringName input)+2
   SendInput, {BS %bslen%}
   SendInput, {Raw}
   (LTrim
      Hi%name%, please update the status of this ticket
   )
} else {
   bslen:=StrLen(A_ThisHotstringName)+1
   SendInput, {BS %bslen%}
}
return

...type "-status" & press enter twice to get...

Code:
Hi, please update the status of this ticket

...type "-status:Name" & press enter to get...

Code:
Hi Name, please update the status of this ticket

...I even added a continuation section to my example, so you could see one working...

Would it be better to have a -name Hotstring that don't expand to anything, but sets a name var for the rest of the Hotstrings?...do you use more than one Hotstring at a time on the same name?
Back to top
djmundy



Joined: 18 Mar 2010
Posts: 3

PostPosted: Thu Mar 18, 2010 3:29 am    Post subject: Reply with quote

Wow, thanks for that, I never could have figured that out on my own! It works awesomely.

I switch back and forth a lot, each time I use a hotstring it's with a new name. So I don't think having a -name hotstring would help me out much.

The one you've just written for me is exactly what I need and I'll get so much use out of this. Thank you very much for your efforts.

Kind regards,
Daniel Mundy
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Mar 18, 2010 3:39 am    Post subject: Re: Email Templates - Can I use variables? Reply with quote

Slightly better (updated)...

Code:
:b0:-status::
A_ThisHotstringName:=RegExReplace(A_ThisHotkey, "^:.*:")
Input, input, v, {Enter}{Escape}
bslen:=StrLen(A_ThisHotstringName input)+1
if (errorlevel="EndKey:Enter") {
   bslen++
}
SendInput, {BS %bslen%}
if (errorlevel="EndKey:Enter") {
   name:=input!="" ? " " input:""
   SendInput, {Raw}
   (LTrim
      Hi%name%, please update the status of this ticket
   )
} else {
   ;//SendInput, <EndKey:Else>
}
return
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group