我使用这样的代码自动执行一些菜单单击,而不是每次都自己执行这些操作:
tell application "System Events" to tell process "myApp"
click something and so on
end tell
现在,为了在 osx lion 沙箱中实现此功能,我的权利文件如下所示(进行了大量研究来弄清楚这一点):
<?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>
现在,如上帝所愿,苹果拒绝了这个应用程序,因为我正在访问com.apple.systemevents
。有没有办法解决使用系统事件
单击指定应用程序菜单中的指定菜单项?
最佳答案
没有。将 UI 事件发送到另一个进程本质上是对应用程序沙箱的破坏。
关于objective-c - 有没有办法使用 AppleScript 单击 osx 菜单项而不访问 "System Events"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13128364/