【发布时间】:2021-07-14 19:47:52
【问题描述】:
我想使用 Automator 和 AppleScript 在 Safari 中填写表格。我有一个看起来像这个玩具示例的功能脚本:
on run {}
tell application "System Events" to keystroke "Hello"
tell application "System Events" to keystroke tab
tell application "System Events" to keystroke "World"
end run
当我在浏览器的特定位置时,我希望使用键盘快捷键执行它。但是,当我这样做时,我遇到了权限问题:
The action "Run AppleSCript" encountered an error:
"System Events got an error: Automator Workflow Runner
(WorkflowServiceRunner, my_script_name) is not allowed to send keystrokes"
在System Prefrences -> Security & Privacy -> Privacy -> Accessibility 中,我已允许Automator 和AppleScript Utility,在Automation 选项卡下,我已允许System Events 用于Safari。
如果我也允许在 Accessibility 中使用 Safari,我可以让它工作,至少是暂时的,但这似乎 太激烈并且存在安全风险,让 Safari 始终拥有完全控制权只是为了不时运行一个脚本。
我应该如何处理这个问题?我希望脚本易于使用,并且不想每次都进入设置以临时允许 Safari。或者这也可以自动化吗?是否有与 Automator 和 AppleScript 完全不同的方法可以让我以更加用户友好和安全的方式执行此操作?基本上,我想做一些类似于 AutoHotKey 在 Windows 中能够做的事情。
【问题讨论】:
标签: macos safari applescript automator