gpt4 book ai didi

macos - osx-以编程方式打开“隐私”>“辅助功能”窗口

转载 作者:行者123 更新时间:2023-12-02 02:49:13 25 4
gpt4 key购买 nike

我正在开发需要从“系统偏好设置”>“安全和隐私”>“隐私”>“辅助功能”启用的应用程序。

现在,我正在使用以下代码打开下面屏幕截图中显示的窗口:

-(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];
}

但不一定会打开“辅助功能”选项卡。相反,它会打开之前打开的选项卡。

所以请建议我修改此代码的方法,该代码将从该窗口的侧面菜单中专门打开“辅助功能”选项卡。

enter image description here

提前致谢。

最佳答案

https://macosxautomation.com/system-prefs-links.html有一个页面包含许多(但不是全部)各种首选项 Pane 的链接。通过一些猜测,我能够验证这些调用在 macOS Mojave beta 7 下是否有效。当用户拒绝访问应用程序可以访问的设备时,我使用这些调用引导用户进入正确的 Pane 。没有就跑。

// 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"]];

关于macos - osx-以编程方式打开“隐私”>“辅助功能”窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27856351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com