com.automator.runner.xpc 不允许辅助访问 - 运行快速操作时无法单击 [英] com.automator.runner.xpc is not allowed assistive access - cannot click when running a quick action
问题描述
我有一个运行需要单击按钮的 AppleScript 程序的快速操作.但是,当它到达点击阶段时,它会显示一条错误消息:
I have a Quick Action that runs an AppleScript program which needs to click a button. However, when it gets to the clicking stage, it displays an error message:
com.automator.runner.xpc 不允许辅助访问
com.automator.runner.xpc is not allowed assistive access
我尝试在系统偏好设置">安全和隐私">完整磁盘访问"下授予它权限,但它只允许我将应用程序添加到列表中,而这是一项快速操作(服务).
I've tried to give it permissions under System Preferences > Security and Privacy > Full Disk Access, but it only lets me add applications to the list, whereas this is a Quick Action (service).
tell application "System Events"
tell process "NotificationCenter"
click button "End" of window 1
end tell
end tell
它应该刚刚点击了按钮,但返回了上面给出的错误消息.
It should have just clicked the button, but returned the error message as given above.
关于为什么这不起作用的任何想法?有没有办法给 com.automator.runner.xpc 全盘访问权限?
Any ideas as to why this doesn't work? Is there a way for me to give com.automator.runner.xpc full disk access?
推荐答案
这是包含 AppleScript 操作的自动化服务的一个已知问题.我想 Gatekeeper 不喜欢它们,因为它看起来像代码注入.
This is a known problem with automator services that have AppleScript actions in them. I suppose Gatekeeper doesn't like them because it looks like code injection.
解决方法(直到 Apple 采取措施解决问题)是在您的操作中使用 AppleScript 并将其转换为独立的 AppleScript 应用程序:将代码复制到脚本编辑器并保存文件,选择 Application 从文件格式菜单.将此脚本应用程序添加到辅助功能安全"窗格 — 系统偏好设置-> 安全性 &Privacy->Privacy->Accessibility — 它应该通过 GateKeeper 的要求.然后您有一个选择,具体取决于您的设置:
The workaround (until Apple does something to fix the problem) is to take the AppleScript in your action and turn it into a stand-alone AppleScript application: copy the code into Script Editor and save the file, choosing Application from the File Format menu. Add this script app to the Accessibility Security pane — System Preferences->Security & Privacy->Privacy->Accessibility — and it should pass GateKeeper's muster. Then you have a choice, depending on your setup:
- 在 Automator 中创建一个调用应用的快速操作.
照常创建快速操作,并使用启动应用程序操作来运行脚本应用程序.这应该作为一项服务或作为 Finder 预览窗格中的快速操作
Create a Quick Action as normal, and use the Launch Application action to run the script app. This should work as a service or as a Quick Action in the Finder preview pane
- 将脚本应用程序本身变成一项服务.
在 Finder 中,找到脚本应用程序,然后从上下文菜单中选择显示包内容".深入到文件info.plist",在纯文本编辑器中打开它并在一个新的键值单元中进行编辑,如下所示:
In the Finder, find the script app, then select "Show Package Contents" from the contextual menu. Drill down to the file "info.plist", open it in a plain-text editor and edit in a new key-value unit that looks like:
<?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>NSServices</key>
<array>
<dict>
<key>NSBackgroundColorName</key>
<string>background</string>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Service Name</string>
</dict>
<key>NSMessage</key>
<string>run</string>
</dict>
</array>
</dict>
</plist>
... 确保不删除或损坏脚本编辑器为脚本应用程序生成的任何默认 xml.保存修改后的 info.plist 文件,将脚本应用程序放在 ~/Library/Services 中.这似乎只能作为一项服务运行(我无法让它们显示在扩展"首选项窗格中).
... making sure not to delete or damage any of the default xml that Script Editor generates for script apps. Save the revised info.plist file, place the script app in ~/Library/Services. This only seems to work as a service (I can't get them to show up in the Extensions preference pane).
这篇关于com.automator.runner.xpc 不允许辅助访问 - 运行快速操作时无法单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!