I'm working on the following script to create an Outlook 2016 e-mail shortcut. The basic logic should be that hitting alt-F7 opens up a new e-mail, and if Outlook isn't already open, then Outlook should open, pause, and then open the e-mail. Here's what I have so far:
Code: Select all
!F7::
If !WinExist("ahk_exe OUTLOOK.EXE"){
run, Outlook.EXE
Sleep, 6000
}
m := ComObjActive("Outlook.Application").CreateItem(0)
m.Display
return
If Outlook is already open, this works just fine. If Outlook is not open, then this script does open Outlook properly but then returns an "Operation unavailable" error stemming from the comObjectActive() call.
I only have about 2 hrs of AHK experience under my belt, but I suspect this is because I need to have COM actually switch to Outlook as the active window?
Any help would be greatly appreciated.