0

I use code like this to do some menu clicks automatically instead of doing them myself every time again:

tell application "System Events" to tell process "myApp"
   click something and so on
end tell

Now, to make this work in the osx lion sandbox, my entitlements file looks like this (done a lot of research to figure this out):

<?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.temporary-exception.apple-events</key>
        <array>
            <string>com.apple.systemevents</string>
            <string>com.apple.iphonesimulator</string>
        </array>
    </dict>
</plist>

And now, as god wants, apple rejects this app because I am accessing com.apple.systemevents. Is there any way to workaround using System Events to click specified menu items in the menu of a specified app?

Thomas Kekeisen
  • 4,355
  • 4
  • 35
  • 54

2 Answers2

3

No. Sending UI events to another process is inherently a breach of application sandboxing.

0

I know it has been a while, I just found your question.

For what its worth, you may want to look into MouseTools and Click utilities : http://www.hamsoftengineering.com/codeSharing/MouseTools/MouseTools.html

http://hints.macworld.com/article.php?story=2008051406323031

The Objective-C code comes with it. I have successfully used that inside my apps to click other parts of the screen without AppleScript.

Another way is to use JavaScript for UI automation. Look for these keywords on the Apple developer site. I would love to post the links but not possible because forum limits :(

In both cases you will have to add a Temporary Entitlement to your app for the click to work within sandbox.

Mitch Match
  • 339
  • 4
  • 14