macOS Mojave,Automator“未授权将Apple事件发送到系统事件。”

问题描述 投票:28回答:8

在我更新到Mojave后,我再也无法使用我之前使用过的自动机服务了。 enter image description here

  • 在安全和隐私方面,我已经检查了AppleScript编辑器。

你看到我的代码有什么问题,或者这是最新macOS的问题?

脚本

on run {input, parameters}
set pathList to {}
repeat with itemNum from 1 to count of input
    tell application "System Events"
        copy POSIX path of (container of (item itemNum of input)) to end of pathList
    end tell
end repeat
return pathList
end run

enter image description here

enter image description here

automator macos-mojave
8个回答
20
投票

这绝对是Mojave新安全框架的一部分。在terminal尝试

osascript -e 'tell application "Finder"' -e 'set _b to bounds of window of desktop' -e 'end tell'

你可能会收到:

36:42: execution error: Not authorized to send Apple events to Finder. (-1743)

在第一次执行时应该发生的是Finder打开一个对话框,通知您terminal正在请求向Finder发送事件的权限。如果您允许,那么terminal将被添加到System Preferences > Security & Privacy > Automation的Automation页面中:

enter image description here

我目前看到两个问题:

  • 对脚本操作的请求权限的实现似乎被窃听;我已经运行了其他脚本请求将事件发送到Safari的权限,并且Finder没有提示权限,它只返回错误。
  • 简化的自动化需要某种类型的机制来授予先验权限;一个例子是使用带有Ansible的AppleScript并且无法预加载授权

其他人已经写了更多关于此的信息:

希望这能在Mojave发布之前解决,因为它会严重影响macOS的自动化功能。


10
投票

我在运行AppleScript .app应用程序时遇到了类似的错误。我收到以下错误:

Not authorized to send Apple events to Finder. (-1743)

解决方法是从.scpt.applescript源代码重新导出应用程序。这会生成一个新的.app应用程序,在我的案例中成功运行。首次启动需要批准(以及一些后续启动),并且该应用程序已添加为Settings -> Security & Privacy -> Privacy -> Automation下的条目。


7
投票

以下是我所做的,为我解决了这个问题。我转到系统偏好设置>安全和隐私>辅助功能(左侧选项)>(输入系统密码)>单击Automator(或您要启用的应用程序)和TADA它可以工作。


7
投票

我在打开gitk时面临同样的错误。

启动脚本出错:执行错误:未授权将Apple事件发送到系统事件。 (-1743)


转到Settings -> Security & Privacy -> Privacy -> Automation -> Privacy tab并检查System Events复选框。

enter image description here


5
投票

更新:更新到最新的公共测试版(截至2018年8月4日)为我解决了这个问题。在此之前,问题确实存在于莫哈韦的所有公共贝塔中。


原始回复:

只是想让你知道我和其他朋友都遇到了这个完全相同的问题,使用Applescript的不同Automator工作流程(与你的不同)。手动激活(Finder - >服务 - >单击项目)和键盘快捷键激活都会出现问题。

更奇怪的是,在Automator内部进行测试时,工作流程表现非常出色。

我已经通过反馈助理提交了一份错误报告,并建议其他任何看到这一点的人也会这样做!吱吱作响的轮子和所有......

Automator - Permissions error. "The action “Run AppleScript” encountered an error: “Not authorized to send Apple events to System Events.”"

Automator workflow performing well inside Automator


3
投票

我使用以下步骤解决了同样的问题。打开Plist并在其中添加以下键

<key>NSAppleEventsUsageDescription</key>
<string>Please give access to Export details to Outlook</string>

当应用程序开始执行脚本时,您将获得一个允许或禁止的确认弹出窗口。如果单击“允许”,它将执行脚本。


0
投票

我试图通过击键将当前日期插入到Reminders应用程序中。我没有使用推荐的“设置 - >安全和隐私 - >隐私 - >辅助功能 - > Automator”,而是添加了Reminders而不是Automator,这样就可以允许使用keystroke命令。令人讨厌的是,它只允许对特定应用程序执行操作,但似乎就是这种情况。


0
投票

在Mojave发布几个月后,我仍然在发送按键时遇到问题。对我来说,奇怪的是修复是去系统偏好 - >安全和隐私 - >隐私选项卡 - >用你的密码解锁 - >从辅助行中的应用程序列表中删除(使用减号按钮)Automator。也许在我的脚本可以再次发送键击之前,运行需要删除的beta的东西。

编辑:退出系统偏好设置后,我再次收到警报错误。将Automator.app重新添加到Accessibility行似乎已经解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.