Closed Avastgard closed 1 year ago
Thanks, I'll try to work something out.
In case anyone is facing the same problem as I was, here's the workaround solution I came up with:
OutlookSearch(searchstr)
{
Send "^#{Left}" ; goes to the first virtual desktop, where I always have my outlook window. Still don't know how to find a window across several virtual desktops
Sleep 100
WinActivate("ahk_class rctrl_renwnd32") ; Activate the Outlook window
Sleep 500
Send "^{y}" ; Opens the "Go to Folder" window in Outlook.
Sleep 50
Send "arch" ; Types "arch", so Archive is selected in the list
Send "{Enter}" ; Effectively opens the Archive folder so the rest of the actions can be performed there
Sleep 500
searchstr := StrReplace(searchstr, "!", " hasattachments:yes")
olApp := GetOutlookCom()
static olSearchScopeCurrentFolder := 0 ; Changed the scope so it only looks at the current folder (Archive)
olApp.ActiveExplorer.Search(searchstr, olSearchScopeCurrentFolder)
ControlSend "{Tab}", "RICHEDIT60W1", "ahk_class rctrl_renwnd32" ; Send Tab to hide the "suggested searches" drop down
return
}
Try looking through this documentation: https://learn.microsoft.com/en-us/office/vba/api/outlook.olsearchscope
At a quick glance, Archive isn't an option and it might be a bit trickier.