How to execute Outlook 2010 macro with AutoHotKey?
Having found that I can't bind custom keyboard shortcuts to macros I've written for Outlook 2010, I turned to AutoHotKey and have a working solution, but it's clumsy. Here is one script and I have two more that execute different macros.
#IfWinActive, Inbox
^!1::
Send, {ALTDOWN}{F8}{ALTUP}
WinWaitActive, ahk_class #32770, Macros, 0
Send, ActionSelectedMessages{ALTDOWN}r{ALTUP}
return
It sends Alt-F8 to open the Macros dialog, waits for the window to open, then sends the name of the macro followed by Alt-R to run it. This works but is slow and ugly with the dialog opening and closing.
So my question is whether there is any way to execute an Outlook macro from AutoHotKey that will not cause any interface side-effects as this solution does?
It turns out that this is rather easy to do. I had already added my three macros to the home strip in the Outlook ribbon and discovered that you can't bind shortcut keys as you could when adding items to the old toolbar. But what I didn't notice, is that shortcuts are automatically assigned to the new ribbon items, as seen in the screenshot.
Knowing that, it's possible to invoke these functions with three keystrokes; Alt-H, followed by Y1, Y2 or Y3. Taking this a step further I modified my AutoHotKey script to send these keystrokes and have now reduced these to the single keystrokes Alt-1, Alt-2 and Alt-3. Here is the script.
#IfWinActive, ahk_class rctrl_renwnd32
!1::
Send, {ALTDOWN}H{ALTUP}Y1
return
!2::
Send, {ALTDOWN}H{ALTUP}Y2
return
!3::
Send, {ALTDOWN}H{ALTUP}Y3
return
I was able to accomplish something similar by adding it to the Quick Access Toolbar. Right click on whatever button you want a hotkey on, set it to Quick Access Toolbar, and it automatically gets an ALT + # combination.