Hey Folks,
As people who use Mail know – the Mailbox Search is local to the selected mailboxes.
To make a search global you have to manually click the “All” button in the Mailboxes toolbar of the message-viewer window you're searching in.
I do a lot of global searches, and I finally got absolutely sick of reaching for the mouse.
------------------------------------------------------------------------------------------- # Auth: Christopher Stone # dCre: 2017/02/19 00:55 # dMod: 2017/02/19 01:07 # Appl: Mail with System Events # Task: Click “All” button when Mailbox Search field is active. # Libs: None # Osax: None # Tags: @Applescript, @Script, @System_Events, @Click, @All, @Button, @Search, @Field, @Active -------------------------------------------------------------------------------------------
tell application "System Events" tell application process "Mail" tell (first window whose subrole is "AXStandardWindow") if name of first button of toolbar 1 = "Get Mail" then tell checkbox "All" of group 7 if its value = 0 then click else beep end if end tell end if end tell end tell end tell
-------------------------------------------------------------------------------------------
The trick is that once you've selected the “All” button it will NOT get unselected without more mouse-intensive intervention.
I get around this by opening a new message-viewer window whenever I want to do a global search.
When that window is closed its All status goes away too.
** Remember – this is System Events and is sensitive to UI changes – the script may not work on your system without some tweaking.
Tested on macOS Sierra 10.12.3.
|