Any way to not wait for COM action to return?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
ajkessel
Posts: 27
Joined: 12 May 2017, 07:51

Any way to not wait for COM action to return?

Post by ajkessel » 01 Apr 2024, 14:31

I am attempting to automate "show in conversations-->all mailboxes" in Outlook 365:

Code: Select all

Outlook := ComObjActive('Outlook.Application')
Outlook.ActiveExplorer.CommandBars.ExecuteMso('ShowInConversations')
ControlClick "All mailboxes","Microsoft Outlook"
The second line selects "show in conversations," which brings up an Outlook modal dialog box with options "All mailboxes" or "This folder". The problem is the ControlClick line is not executed until after the user makes a choice in the dialog box, thus blocking the goal of automating the process.

Is there any way to essentially "fork" the ExecuteMso line so the ControlClick will run without waiting for the COM action to return? Or would this require AHK_H? I'm hesitant to switch to AHK_H v2 as it is still labeled an alpha release and does not appear to be under active development.

I've also tried SetTimer for a function that calls the ControlClick function, but any timer function does not appear to run until COM has returned control to AHK. The other workaround is to run a separate AHK instance with a separate script that runs ControlClick before triggering the COM action. This seems to accomplish the task but is very clunky.

Any ideas for more elegant workarounds?

Return to “Ask for Help (v2)”