Open an e-mail after opening a program

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
awicz
Posts: 1
Joined: 13 Dec 2017, 13:59

Open an e-mail after opening a program

13 Dec 2017, 14:09

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: scriptor2016 and 311 guests