Input Select Form into AHK Command

Discussion, questions and support.
Post Reply
defrian
Posts: 7
Joined: Jun 2nd, ’16, 14:41

Post by defrian » Jun 8th, ’16, 12:39

Hi,
I searched the forum, but maybe did not get my searchstring right.
I am looking for an elegant way to post the result of a fastkeys input selection box into an AHK command or script.
What I am trying to achive is, I want to have a shortcut that creates an Outlook Task for me but gives me a selection of strings that describe the task for the subject

With Best Regards,
André
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jun 8th, ’16, 13:38

Hi, great question, I'm glad you asked.

There are different ways to do this. One way is to use Insert Another Item macro. Another convenient way in your case would be to use Insert Command Code macro. Variables from Input or selection forms can be used in a script.

For example, create type Send item with the following substitute (use a More menu to create macro fields):

Code: Select all

%INPUT_MyInput%
%CODE_MsgBox%
where the inserted code would be for example:

Code: Select all

MsgBox % INPUT_MyInput
You can use any AutoHotkey syntax. The same principle applies to Selection fields, just use the proper variable names (SELECT_VariableName).
Guest
Posts: 20
Joined: Mar 18th, ’14, 08:46

Post by Guest » Jun 8th, ’16, 15:14

Hi Marko,

thank you for your reply.
I tried it but did not get it to work.
Here is what i did:

1) Createt a New ShortCut Element
2) Inserted %SELECT_task_type% Selection field with two Options
3) Inserted %CODE_createNewTask% which is

Code: Select all

Application := ComObjActive("Outlook.Application")
;example of creating a MailItem and setting it's format to HTML
olTaskItem := 3
TaskItem := ComObjActive("Outlook.Application").CreateItem(olTaskItem)
TaskItem.Subject := %SELECT_task_type%
TaskItem.Display
When I trigger the shortcut I receive the following error:

"Error 0x8001010D - A outgoing request can not be executed because the application sends an input-syncronized request"

I tried several things but could not find the reason myself.
Please help.

With Best Regards,
André
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jun 8th, ’16, 17:07

Andre, I see a Com within the inserted code causes a conflict. I will check what might be the reason. The other issue with my first answer is that when using selection forms, the resulting text is always sent, which you don't want.

Could you use this alternative (Type Command)?:

Code: Select all

Menu Mail, Add
Menu Mail, DeleteAll
Menu Mail, Add, Subject One, MMail
Menu Mail, Add, Subject Two, MMail
Menu Mail, Add, Subject Three, MMail
Menu Mail, Add, Subject One, MMail
Menu Mail, Show
return

MMail:
Application := ComObjActive("Outlook.Application")
;example of creating a MailItem and setting it's format to HTML
olTaskItem := 3
TaskItem := ComObjActive("Outlook.Application").CreateItem(olTaskItem)
TaskItem.Subject := A_ThisMenuItem 
TaskItem.Display
return
defrian
Posts: 7
Joined: Jun 2nd, ’16, 14:41

Post by defrian » Jun 9th, ’16, 10:44

Hi Marko,

thanks for the workaround. works for now.

best regards,
André
Post Reply