Apple Mail preferences

On my new Macbook Pro using High Sierra, Apple has managed to screw up Mail’s preferences somehow - they reset just about every time I start the application. I have a macro which brings up the preferences dialog and sets the values I want. The one hitch is that I need the macro to wait until the preferences dialog is active before starting to set values. How can I do this? I can’t use the title of the window, because that is set to whichever pane was active the last time the preferences dialog was out.

I don't usually like to rely on found image conditions myself, but in this case, maybe it will do the trick. What about using a found image that's fairly unique to Mail's prefs window, like this?

You should be able to do a Pause Until the FrontWindowName of the FrontApp changes.

Where’s an option for “window title changes” My Keyboard Maestro only does title matching.

There is not an exact condition for this, so we have to be a bit creative:

Being a “bit creative” is fine by me. I’ve been using the new macro all day with no problems, so I’d say that does it. Thanks!

1 Like

Hey Julian,

I believe resetting of preferences is a know bug in High Sierra, and I thought that had been fixed in a dot-update. (I’m still using Sierra, so I’m not certain of this.)

System Events can see the window structure, so it’s possible to do this directly with AppleScript and System Events.


# Auth: Christopher Stone
# dCre: 2017/11/10 21:20
# dMod: 2017/11/10 21:33 
# Appl: Mail, System Events
# Task: Open the Preferences window and select the Viewer pane.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Mail, @System_Events, @Open, @Preferences, @Window, @Select, @Viewer, @Pane

tell application "System Events"
   tell application process "Mail"
      tell menu bar 1
         tell menu bar item "Mail"
            tell menu 1
               tell menu item "Preferences…"
                  perform action "AXPress"
               end tell
            end tell
         end tell
      end tell
      set _tmr to 0
      repeat until button "Viewing" of toolbar 1 of (first window whose subrole is "AXStandardWindow") exists
         delay 0.25
         set _tmr to _tmr + 1
         if _tmr > 10 then error "Preferences window not found!"
      end repeat
      tell (first window whose subrole is "AXStandardWindow")
         set winName to its name
         if winName ≠ "Viewing" then
            tell toolbar 1
               tell button "Viewing"
                  perform action "AXPress"
               end tell
            end tell
         end if
      end tell
   end tell
end tell