A simple AppleScript to reveal System Settings’ anchors
I stumbled upon this simple AppleScript while looking for something else, but it's incredibly useful for scripting System Settings…so I'm posting it here in case the original site ever goes away.
To get the names of all the anchors for a selected pane in System Settings, just run this in Script Editor:
1 2 3 | tell application "System Settings" get every anchor of current pane end tell |
Run that on the Desktop pane, for instance, and the output is this:
{anchor "Dock" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings", anchor "HotCorners" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings", anchor "MenuBar" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings", anchor "MissionControl" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings", anchor "Shortcuts" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings", anchor "StageManager" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings", anchor "WindowsApps" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings"}
With that information, you can jump directly to a given area in AppleScript with code like this:
1 2 3 4 5 6 | tell application "System Settings" activate reveal anchor "Shortcuts" of pane id "com.apple.Desktop-Settings.extension" of application "System Settings" delay 0.5 -- macro does other stuff here… end tell |
I'd always wondered how people found the anchor names, and now I know.