Apple Scripting for opening system preferences settings

Hi, I tried opening System Preferences > Keyboard > Text tab and it works, but opening System Preferences > Keyboard > Shortcuts tab isn’t working, although they are almost identical. What’s wrong here? Also, didn’t find any documentation for this :no_mouth:

WORKS

tell application "System Preferences"
	activate
	set current pane to pane id "com.apple.preference.keyboard"
	delay 2
	tell current pane to reveal anchor "Text"
end tell

DOES NOT WORK

tell application "System Preferences"
	activate
	set current pane to pane id "com.apple.preference.keyboard"
	delay 2
	tell current pane to reveal anchor "Shortcuts"
end tell
  • Can anyone help with this?
  • Where can I find all these identifiers (or ids or pane, settings etc) and other documentation related to apple script

The names of the anchors in that pane are:

InputSources
shortcutsTab
keyboardTab_ModifierKeys
keyboardTab
Text
Dictation

Thus you must use “shortcutsTab” instead of “Shortcuts”.

1 Like

Thanks, shortcutsTab works. How do I find the names of these names? Is there an app or docs that list them?

This might help

https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/AutomatetheUserInterface.html

1 Like

I used ScriptDebugger. I’d be lost without it.

@JohnAtl’s suggestion also works, e.g.

tell application “System Preferences”
activate
set current pane to pane id “com.apple.preference.keyboard”
delay 2
name of every anchor in current pane
end tell

1 Like

I used the above to generate the following for my sys prefs. Some of yours may differ of course:

Ids to script System prefs on Mac

“com.apple.preference.universalaccess”

anchor “Accessibility_Shortcut” of pane id “com.apple.preference.universalaccess”

anchor “Seeing_Cursor” of pane id “com.apple.preference.universalaccess”

anchor “Seeing_Zoom” of pane id “com.apple.preference.universalaccess”

anchor “Keyboard” of pane id “com.apple.preference.universalaccess”

anchor “Seeing_VoiceOver” of pane id “com.apple.preference.universalaccess”

anchor “Virtual_Keyboard” of pane id “com.apple.preference.universalaccess”

anchor “TextToSpeech” of pane id “com.apple.preference.universalaccess”

anchor “Dwell” of pane id “com.apple.preference.universalaccess”

anchor “Dictation” of pane id “com.apple.preference.universalaccess”

anchor “Switch” of pane id “com.apple.preference.universalaccess”

anchor “Siri” of pane id “com.apple.preference.universalaccess”

anchor “Alternate_Pointer_Actions” of pane id “com.apple.preference.universalaccess”

anchor “Mouse” of pane id “com.apple.preference.universalaccess”

anchor “Captioning” of pane id “com.apple.preference.universalaccess”

anchor “Media_Descriptions” of pane id “com.apple.preference.universalaccess”

anchor “Head_Pointer” of pane id “com.apple.preference.universalaccess”

anchor “General” of pane id “com.apple.preference.universalaccess”

anchor “Seeing_ColorFilters” of pane id “com.apple.preference.universalaccess”

anchor “Seeing_Display” of pane id “com.apple.preference.universalaccess”

anchor “Hearing” of pane id “com.apple.preference.universalaccess”

“com.apple.preferences.AppleIDPrefPane”

“com.backblaze.BackblazeBackup”

“com.apple.preferences.Bluetooth”

anchor “Bluetooth” of pane id “com.apple.preference.dock”

anchor “Siri” of pane id “com.apple.preference.dock”

anchor “Clock” of pane id “com.apple.preference.dock”

anchor “Battery” of pane id “com.apple.preference.dock”

anchor “ScreenMirroring” of pane id “com.apple.preference.dock”

anchor “Display” of pane id “com.apple.preference.dock”

anchor “Sound” of pane id “com.apple.preference.dock”

anchor “NowPlaying” of pane id “com.apple.preference.dock”

anchor “Spotlight” of pane id “com.apple.preference.dock”

anchor “Wi-Fi” of pane id “com.apple.preference.dock”

anchor “Dock” of pane id “com.apple.preference.dock”

anchor “KeyboardBrightness” of pane id “com.apple.preference.dock”

anchor “DoNotDisturb” of pane id “com.apple.preference.dock”

anchor “AirDrop” of pane id “com.apple.preference.dock”

anchor “AccessibilityShortcuts” of pane id “com.apple.preference.dock”

anchor “TimeMachine” of pane id “com.apple.preference.dock”

anchor “UserSwitcher” of pane id “com.apple.preference.dock”

“com.econtechnologies.preference.chronoagent”

“com.apple.preference.datetime”

“com.apple.preference.desktopscreeneffect”

“com.apple.preference.displays”

anchor “displaysDisplayTab” of pane id “com.apple.preference.displays”

anchor “displaysNightShiftTab” of pane id “com.apple.preference.displays”

anchor “displaysArrangementTab” of pane id “com.apple.preference.displays”

anchor “displaysColorTab” of pane id “com.apple.preference.displays”

anchor “displaysGeometryTab” of pane id “com.apple.preference.displays”

“com.apple.preference.dock”

“com.apple.preference.energysaver”

“com.apple.preferences.extensions”

“com.apple.preferences.FamilySharingPrefPane”

“com.apple.preference.general”

“com.apple.preferences.internetaccounts”

anchor “com.apple.account.Google” of pane id “com.apple.preferences.internetaccounts”

anchor “com.apple.account.aol” of pane id “com.apple.preferences.internetaccounts”

anchor “com.apple.account.126” of pane id “com.apple.preferences.internetaccounts”

anchor “com.apple.account.163” of pane id “com.apple.preferences.internetaccounts”

anchor “com.apple.account.qq” of pane id “com.apple.preferences.internetaccounts”

anchor “com.apple.account.Exchange” of pane id “com.apple.preferences.internetaccounts”

anchor “com.apple.account.Yahoo” of pane id “com.apple.preferences.internetaccounts”

anchor “InternetAccounts” of pane id “com.apple.preferences.internetaccounts”

“com.apple.preference.keyboard”

anchor “InputSources” of pane id “com.apple.preference.keyboard”

anchor “shortcutsTab” of pane id “com.apple.preference.keyboard”

anchor “keyboardTab_ModifierKeys” of pane id “com.apple.preference.keyboard”

anchor “keyboardTab” of pane id “com.apple.preference.keyboard”

anchor “Text” of pane id “com.apple.preference.keyboard”

anchor “Dictation” of pane id “com.apple.preference.keyboard”

“com.apple.Localization”

“com.apple.preference.expose”

“com.apple.preference.mouse”

“com.apple.preference.network”

anchor “VPN” of pane id “com.apple.preference.network”

anchor “PPP” of pane id “com.apple.preference.network”

anchor “Bluetooth” of pane id “com.apple.preference.network”

anchor “Advanced Ethernet” of pane id “com.apple.preference.network”

anchor “DNS” of pane id “com.apple.preference.network”

anchor “Advanced VPN” of pane id “com.apple.preference.network”

anchor “WINS” of pane id “com.apple.preference.network”

anchor “6to4” of pane id “com.apple.preference.network”

anchor “Bond” of pane id “com.apple.preference.network”

anchor “Ethernet” of pane id “com.apple.preference.network”

anchor “WWAN” of pane id “com.apple.preference.network”

anchor “Advanced Modem” of pane id “com.apple.preference.network”

anchor “Proxies” of pane id “com.apple.preference.network”

anchor “Advanced Wi-Fi” of pane id “com.apple.preference.network”

anchor “Modem” of pane id “com.apple.preference.network”

anchor “VLAN” of pane id “com.apple.preference.network”

anchor “PPPoE” of pane id “com.apple.preference.network”

anchor “TCP/IP” of pane id “com.apple.preference.network”

anchor “802.1X” of pane id “com.apple.preference.network”

anchor “FireWire” of pane id “com.apple.preference.network”

anchor “VPN on Demand” of pane id “com.apple.preference.network”

anchor “Wi-Fi” of pane id “com.apple.preference.network”

“com.apple.preference.notifications”

“com.apple.preference.printfax”

“com.apple.preferences.configurationprofiles”

“com.apple.preference.screentime”

“com.apple.preference.security”

anchor “Privacy_Microphone” of pane id “com.apple.preference.security”

anchor “Privacy_Reminders” of pane id “com.apple.preference.security”

anchor “Privacy_Calendars” of pane id “com.apple.preference.security”

anchor “Firewall” of pane id “com.apple.preference.security”

anchor “Privacy_Assistive” of pane id “com.apple.preference.security”

anchor “Privacy_LocationServices” of pane id “com.apple.preference.security”

anchor “Privacy_Contacts” of pane id “com.apple.preference.security”

anchor “General” of pane id “com.apple.preference.security”

anchor “Advanced” of pane id “com.apple.preference.security”

anchor “Privacy_Accessibility” of pane id “com.apple.preference.security”

anchor “Privacy_Camera” of pane id “com.apple.preference.security”

anchor “Privacy_SystemServices” of pane id “com.apple.preference.security”

anchor “FDE” of pane id “com.apple.preference.security”

anchor “Privacy” of pane id “com.apple.preference.security”

anchor “Privacy_AllFiles” of pane id “com.apple.preference.security”

“com.apple.preferences.sharing”

anchor “Services_PersonalFileSharing” of pane id “com.apple.preferences.sharing”

anchor “Services_RemoteAppleEvent” of pane id “com.apple.preferences.sharing”

anchor “Services_ARDService” of pane id “com.apple.preferences.sharing”

anchor “Internet” of pane id “com.apple.preferences.sharing”

anchor “Services_DVDorCDSharing” of pane id “com.apple.preferences.sharing”

anchor “Main” of pane id “com.apple.preferences.sharing”

anchor “Services_RemoteLogin” of pane id “com.apple.preferences.sharing”

anchor “Services_ContentCaching” of pane id “com.apple.preferences.sharing”

anchor “Services_ScreenSharing” of pane id “com.apple.preferences.sharing”

anchor “Services_WindowsSharing” of pane id “com.apple.preferences.sharing”

anchor “Services_PrinterSharing” of pane id “com.apple.preferences.sharing”

“com.apple.preference.sidecar”

“com.apple.preference.speech”

“com.apple.preferences.softwareupdate”

“com.apple.preference.sound”

anchor “effects” of pane id “com.apple.preference.sound”

anchor “input” of pane id “com.apple.preference.sound”

anchor “output” of pane id “com.apple.preference.sound”

“com.apple.preference.spotlight”

“com.apple.preference.startupdisk”

“cl.fail.lordkamina.SwiftDefaultApps”

“com.apple.prefs.backup”

“com.apple.preference.trackpad”

“com.apple.preferences.users”

anchor “mobilityPref” of pane id “com.apple.preferences.users”

anchor “loginOptionsPref” of pane id “com.apple.preferences.users”

anchor “startupItemsPref” of pane id “com.apple.preferences.users”

anchor “passwordPref” of pane id “com.apple.preferences.users”

“com.manytricks.Witch”

1 Like

Wait, did you use ScriptDebugger to generate all this? What’s the script for generating this

I ran this script

tell application "System Preferences"
	get every anchor of current pane
end tell

which I obtained from here, against each of my sys pref panes and then used Bbedit to cleanup the formatting and save for future reference.

2 Likes