以下代码试图打开代理设置对话框,
NSAppleScript *a = [[NSAppleScript alloc] initWithSource:@"tell application \"System Preferences\"\nset current pane to pane \"com.apple.preference.network\"\nactivate\nend tell\ntell application \"System Events\" to tell process \"System Preferences\" to tell window 1\n click button -3\nclick radio button -2 of tab group 1 of sheet 1\nend tell"];
[a executeAndReturnError:nil];
在我将 Mac OS 升级到 10.9 之前,它一直运行良好。苹果脚本的第二部分,
tell application \"System Events\" to tell process \"System Preferences\" to tell window 1\n click button -3\nclick radio button -2 of tab group 1 of sheet 1\nend tell
它不再起作用了。所以如果有人能告诉我原因,我将不胜感激。
编辑:这是我的 .entitlements 文件信息,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.preference</key>
<array>
<string>com.apple.preference</string>
<string>com.apple.systemevents</string>
</array>
</dict>
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.preference</string>
<string>com.apple.systemevents</string>
</array>
</dict>
</plist>