When I compile a script that uses GUI scripting and run it for the first time, there is a warning
[The Name Of My Script] is not allowed assistive access.
To resolve this issue, I need to enable my script under System Settings > Privcacy & Security > Accessibility:
But to click System Settings > Privacy & Security > Accessibility is quite a tedious thing.
I found a 2017 year script that opens the “Keyboard” pane, assuming that I would be able to further adopt it to my case.
tell application "System Settings"
activate
set current pane to pane id "com.apple.preference.keyboard"
delay 1
tell application "System Events"
click radio button "Dictation" of tab group 1 of window "Keyboard" of application process "System Preferences"
end tell
end tell
But for some reason it doesn’t work, there is an error:
System Settings got an error: Can’t set pane id “com.apple.preference.keyboard” to pane id “com.apple.preference.keyboard”.
Why is that? And if the IDs of the “System Settings” panes were changed since 2017, how can I get the new ones?
Hi john202307.
tell application "System Settings"
activate
return {name, id} of panes
end tell
Or:
tell application "System Settings"
activate
return id of pane "Keyboard"
end tell
--> "com.apple.Keyboard-Settings.extension"
While it’s possible to set the current pane to a pane, System Settings also has a reveal
command, which works with both panes and anchors:
tell application "System Settings"
activate
reveal anchor "Dictation" of pane id "com.apple.Keyboard-Settings.extension"
end tell
1 Like
There is also a handy collection of command line URL schemes at GitHub - bvanpeski/SystemPreferences: Navigating System Prefences/Settings on macOS . These can also be used with open location
in a script.
2 Likes
Found a wealth of references there, but for those of us who still have a lot to learn, how would something like “open x-apple.systempreferences:com.apple.BluetoothSettings” be worked into a script?
For those URL schemes, you would use open location
instead of open
, for example
open location "x-apple.systempreferences:com.apple.BluetoothSettings"
2 Likes
Thank you, I must have tried at least a half dozen different versions of “open location”scripts, but for some reason it never occurred to me to drop the “open” at the front of the command line command.
For some reason, the very first time I ran your first script, I ended up with a list of 44 items. All subsequent runs produce only one item (screenshot attached). Any ideas?

Think I may have figured it out. This change to the script produces the full 44 items, but only on the second run, which is strange.
tell application "System Settings"
activate
return {name, id} of every pane
end tell
It seems if ‘System Settings’ is not already running, the time between the activate command and the getting of the panes is too short. You must put in a delay to let System Settings fully load before trying to get the panes info.
tell application "System Settings"
if not running then
activate
delay 1
end if
return {name, id} of every pane
end tell
Thank you. I knew there had to be some logical explanation. The second run success should have given me a hint.