The following code is trying to open the proxies settings dialog,
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];
it has been working well until I upgrade my Mac OS to 10.9. The second part of the applescript,
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
it doesn't work any more. so if any one could tell me the reason, I would be very grateful.
edit: Here is my .entitlements file information,
<?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>
UPDATE TO ANSWER
Ok after a little play with sandboxing which I have never used before: I used the option :
So in the Entitlements file.
You need to add the Entitlement:
com.apple.security.temporary-exception.apple-events
Set it as an Array
Then add two items to it.
com.apple.systempreferences
com.apple.systemevents
These items should be strings
Save the file.
This is All I have done and there are no other entitlements added
On my tests the System prefs opened and the Proxies tab was selected.
This also shows any App you that even if you tell one app to tell another app/process ..do something. Both apps must be in the list
A slight change to your setup should fix your issue:
By doing this I notice that in your edit you show you have added:
com.apple.preferences.
So you just need to change it to the correct id which is com.apple.systempreferences
Original part of Answer:
If you read the AboutAppSandbox link I provided you in the comments. Which I suggested as I assumed your app was sandboxed already. You should have seen:
( I have literally just read this myself )
This implies with regards to accessibility APIs in assistive apps And sandoxing, you can do one or the other but not both.
There is however this bit also but you will need to investigate its implications
And reading further there is another possible approach
The strategy you are using is not what I would want from an app. And I think using GUI like this leaves a lot of room for it to fail.Either because of element tree changes in the GUI or user interaction takes focus away from the intended target of the system events.
I think the better approach would be to inform the user to change the proxy their selves.