I am trying to access the Privacy -> Accessibility tab using Applescript. Can anyone help me?
I need to display a list of all the programs in the section:
- Accessibility
- Camera
- Microphone
- Photos
- etc...
The request itself and the output in the terminal using osascript -e
.
It is necessary to exclude interaction with the GUI. Here's what I managed to find
osascript -e 'tell application "System Events" to get the name of every login item'
I need to find the same solution for Accessibility? And get the result the same as in the screenshot below.
The main goals are
- Locally get the information contained in Security & Privacy 2)Connect to mac OS via SSH and get the information contained in Security & Privacy. If this is not possible, then how to display the information using a single Apple script.
Testing with the remote system being macOS Big Sur 11.6 and having checked [√] Allow full disk access for remote users in System Preferences > Sharing > Remote Login on the remote system, then the example shell script code executed in Terminal on the local system in a
ssh
session to the remote system will give you a raw dump of what's listed under Accessibility in System Preferences > Security & Privacy > Privacy without the need for UI Scripting with AppleScript.On the test system its output was:
If you really have a need to use AppleScript you could, however, say you needed the output to be pretty. In other words, using an AppleScript script saved as a shell script using a
#!/usr/bin/osascript
shebang the output on the same remote system would be e.g.:Example AppleScript code:
Notes:
I created, saved and made executable the example AppleScript code, shown above, on the local system and then copied it the from the local system to the remote system using
scp
.Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g.
delay 0.5
, with the value of the delay set appropriately.