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 

GUI for canned answers in email - help with concept needed

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



Joined: 17 Nov 2009
Posts: 12

PostPosted: Tue Mar 16, 2010 3:29 pm    Post subject: GUI for canned answers in email - help with concept needed Reply with quote

I send a lot of common responses via email so I want to create a GUI to select and paste canned answers into emails.

This is the first GUI I've attempted and the more I think about it, the more trouble I have wrapping my head around the execution.

What I want to do:

Build a GUI with a drop down list and a submit button. The drop down list would contain a list of common replies. Each item in the list would correspond with a block of text to be pasted into the email. The items in the dropdown list would be in the following format: How to register | How to access archives | How to log on | Etc...

The user should select an item from this list and press the submit button. Upon pressing Submit, the script would paste the block of text associated with the selected item from the drop down list and then close the GUI.

The GUI would be called using a hotstring entered into a blank reply to the original email.

What I'm trying to wrap my head around:

When the user presses the submit button, it would store the selected item as a variable (vCanned) - right? I imagine the script would need an IF statement, that would say something like this:

if vCanned="How to register"
SendInput, BIG BLOCK OF TEXT HERE

else if vCanned="How to access archives"
SendInput, ANOTHER BLOCK OF TEXT WOULD GO HERE

else if vCanned="How to log on"
SendInput, YET ANOTHER BLOCK OF TEXT

and so on...


My question:

Am I on the right track here? I have a feeling I'm completely wrong in how I am trying to do this. Can someone give me an idea of the concepts I should be looking at?
Back to top
View user's profile Send private message
wooly_sammoth



Joined: 12 May 2009
Posts: 634
Location: Gloucester UK

PostPosted: Tue Mar 16, 2010 4:06 pm    Post subject: Reply with quote

You are definately on the right track. A couple of things to mention would be that in your if statements you don't need the small v

Code:

If Caned="How to register
          Send, BIG BLOCK OF TEXT HERE


While your If statement method will definitely work, you might consider a slightly different approach to allow for easy changing of the text that is sent.

I would create a sperate .txt file for each reply. I would name each of them with the description contained in the drop down list

eg. How to register.txt
How to access archives.txt

This would be beneficial for two reasons.

1. To change the text you need only edit that text file rather than the ahk code. This could be useful if other people wanted to use your application as they could personalise the replies without accessing the code

2. the only code that would be needed after your submit button would be

Code:
ButtonSubmit:
Gui, Submit
FileRead, Answer_Text, %Canned%.txt
SendInput, %Answer_Text%
Return


which makes the whole thing easier to maintain
Back to top
View user's profile Send private message Visit poster's website
Jinan



Joined: 08 Mar 2010
Posts: 11

PostPosted: Tue Mar 16, 2010 4:11 pm    Post subject: Re: GUI for canned answers in email - help with concept need Reply with quote

factory wrote:
Am I on the right track here? I have a feeling I'm completely wrong in how I am trying to do this. Can someone give me an idea of the concepts I should be looking at?

I think you are on the right track. but I am not really sure.
you could try the blow script:
Code:
if (vCanned="How to register")
SendInput, BIG BLOCK OF TEXT HERE

else if (vCanned="How to access archives")
SendInput, ANOTHER BLOCK OF TEXT WOULD GO HERE

else if (vCanned="How to log on")
SendInput, YET ANOTHER BLOCK OF TEXT

It have been tested. but still have a little unstable.
Back to top
View user's profile Send private message
factory



Joined: 17 Nov 2009
Posts: 12

PostPosted: Tue Mar 16, 2010 7:00 pm    Post subject: Reply with quote

Thanks for the advice. This is is helpful information. I'll plug away at it to see if I can figure it out.

I might be back though Embarassed
Back to top
View user's profile Send private message
factory



Joined: 17 Nov 2009
Posts: 12

PostPosted: Wed Mar 17, 2010 1:41 pm    Post subject: Reply with quote

wooly_sammoth wrote:
I would create a sperate .txt file for each reply. I would name each of them with the description contained in the drop down list

eg. How to register.txt
How to access archives.txt

This would be beneficial for two reasons.

1. To change the text you need only edit that text file rather than the ahk code. This could be useful if other people wanted to use your application as they could personalise the replies without accessing the code

2. the only code that would be needed after your submit button would be

Code:
ButtonSubmit:
Gui, Submit
FileRead, Answer_Text, %Canned%.txt
SendInput, %Answer_Text%
Return


which makes the whole thing easier to maintain



I liked your solution so I went with it. I'm encountering an odd problem though. For some reason it takes two presses of my Submit button to paste the text of the file.

Here's the script:

Code:

:*:;can::
;show user input box
Gui, Destroy
Gui, Font, Arial
Gui, Add, Text,, Select Response
Gui, Add, DropDownList, W200 vCanned, How to Register|How to Log On|Accessing Digital Edition|Research Request Guidelines|
Gui, Add, Button, W100 X220 Y25 , Submit
ButtonSubmit:
Gui, Submit
FileRead, Answer_Text, %Canned%.txt
SendInput, %Answer_Text%

Gui, Show, W350 H80, Can Opener


Any idea why it's not pasting on the first press of the button?
Back to top
View user's profile Send private message
OceanMachine



Joined: 15 Oct 2007
Posts: 780
Location: England

PostPosted: Wed Mar 17, 2010 3:06 pm    Post subject: Reply with quote

try this

Code:
:*:;can::
;show user input box
Gui, Font, Arial
Gui, Add, Text,, Select Response
Gui, Add, DropDownList, W200 vCanned, How to Register||How to Log On|Accessing Digital Edition|Research Request Guidelines|
Gui, Add, Button, W100 X220 Y25 , Submit
Gui, Show, W350 H80, Can Opener
Return

ButtonSubmit:
   Gui, Submit
   Gui, Destroy
   FileRead, Answer_Text, %Canned%.txt
   SendInput, %Answer_Text%
Return
Back to top
View user's profile Send private message
factory



Joined: 17 Nov 2009
Posts: 12

PostPosted: Wed Mar 17, 2010 3:16 pm    Post subject: Reply with quote

That works perfectly - thanks much!

So was it the lack of Return in my script which caused the double pressing of the button?
Back to top
View user's profile Send private message
OceanMachine



Joined: 15 Oct 2007
Posts: 780
Location: England

PostPosted: Wed Mar 17, 2010 3:23 pm    Post subject: Reply with quote

factory wrote:
So was it the lack of Return in my script which caused the double pressing of the button?


Yes, basically if you don't return then the script will "fall through" the label and execute everything until it hits a return.
Back to top
View user's profile Send private message
factory



Joined: 17 Nov 2009
Posts: 12

PostPosted: Mon Mar 29, 2010 2:17 pm    Post subject: Reply with quote

Thanks for all the help with this. The GUI is working well and has sped up my productivity.

However, I have a new question:

Is there a way to have variable text within the .txt files I am inserting?

For example, we have multiple websites and sometimes I need to refer to one a specific site in my reply.

Once a .txt file is inserted from the GUI, is there a way to have an option of which website name to insert into a specified place in the inserted text?
Back to top
View user's profile Send private message
wooly_sammoth



Joined: 12 May 2009
Posts: 634
Location: Gloucester UK

PostPosted: Mon Mar 29, 2010 2:46 pm    Post subject: Reply with quote

You could have a place holder within the text. Something like $website
Once you've called the text from the file you can scan it for the place holder and replace it with the specified string.

something like this:

Code:
Website = example.com
FileRead, Gui_Text, Text_File.txt
IfInString, Gui_Text, $Website
{
          StringReplace, Gui_Text, Gui_Text, $Website, %Website%, A
}
Back to top
View user's profile Send private message Visit poster's website
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Wed Mar 31, 2010 1:00 am    Post subject: Reply with quote

Transform, EmailText, DEREF, %TemplateWithVariables%
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
factory



Joined: 17 Nov 2009
Posts: 12

PostPosted: Wed Mar 31, 2010 1:54 pm    Post subject: Reply with quote

[VxE] wrote:
Transform, EmailText, DEREF, %TemplateWithVariables%


Sorry to be dense, but could you please elaborate on this? For example, where would this be inserted into the code? Also, what would I do with %TemplateWithVariables%?
Back to top
View user's profile Send private message
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