本文介绍了macOS Mojave,Automator“未经授权将Apple事件发送到System Events."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到Mojave之后,我将无法再使用以前在以下警报中使用的自动服务.

After I updated to Mojave, I can no longer use the automator service I've previously been using with the alert below.

  • 在安全性和隐私权,我已经检查了AppleScript编辑器.

您是否看到我的代码有任何问题,或者这是最新的macOS的问题?

Do you see any problem with my code or is this the problem of the newest 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

推荐答案

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

This is definitely a part of Mojave's new security framework. In terminal try

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的自动化"页面中:

What is supposed to happen on the first execution is the Finder opens a dialog box informing you that terminal is requesting permission to send events to the Finder. If you allow it, then terminal will get added to the Automation page in System Preferences > Security & Privacy > Automation:

此刻我看到两个问题:

  • 请求脚本操作权限的实现似乎有问题;我已经运行了其他请求权限以将事件发送到Safari的脚本,并且Finder不会提示您输入权限,它只会返回错误.
  • 简化的自动化需要某种机制来授予一个先验权限;一个示例是将AppleScript与Ansible结合使用,并且无法预加载赠金
  • the implementation of requesting permission for the scripting action appears to be bugged; I've run other scripts that request permission to send events to Safari and the Finder doesn't prompt for permission, it just returns an error.
  • streamlined automation requires some type of mechanism to have the permissions granted a priori; an example would be utilizing AppleScript with Ansible and being unable to preload grants

其他人为此撰写了更广泛的信息:

Others have written up more extensive information about this:

  • https://www.felix-schwarz.org/blog/2018/06/apple-event-sandboxing-in-macos-mojave
  • https://forums.developer.apple.com/thread/106949

希望这可以在Mojave发行之前得到解决,因为它会严重影响macOS上的自动化功能.

Hopefully this gets worked out before Mojave ships as it seriously impacts automation capabilities on macOS.

这篇关于macOS Mojave,Automator“未经授权将Apple事件发送到System Events."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 05:38