I am working on the app which needs to be enabled from System Preferences > Security and Privacy > Privacy > Accessibility.
Right now, I am using the following code to open window shown in the screenshot below:
-(IBAction)enableAccessibility
{
NSString *script = @"tell application \"System Preferences\" \n reveal anchor \"Privacy\" of pane id \"com.apple.preference.security\" \n activate \n end tell";
NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:script];
[scriptObject executeAndReturnError:nil];
}
But not necessary that it will open "Accessibility" tab. Instead, it opens previously opened tab.
So Please suggest me the way to modify this code which will open specifically "Accessibility" Tab from the side menu of this window.
Thanks in advance.
https://macosxautomation.com/system-prefs-links.html has a page of links to many, but not all of, the various preference panes. With a little bit of guesswork, I was able to verify that these calls work under macOS Mojave beta 7. I'm using these calls to guide the user to the proper pane when they've denied access to a device that the app can't run without.
// open last Privacy subpane viewed:
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy"]];
// specify a particular subpange
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_Camera"]];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone"]];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_Automation"]];