Applescript 如何从命令行重新加载Safari扩展?

Applescript 如何从命令行重新加载Safari扩展?,applescript,safari-extension,Applescript,Safari Extension,我需要从命令行“重新加载”Safari扩展(稍后还要构建包) 如何做到这一点 为什么? 我希望一步到位——我的代码是用CoffeeScript编写的,因此我还是在编译它 我试过什么? 除了无可救药地用谷歌搜索外,我还尝试使用以下AppleScript: tell application "System Events" tell process "Safari" click the button "Reload" of window "Extension Builder"

我需要从命令行“重新加载”Safari扩展(稍后还要构建包)

如何做到这一点

为什么? 我希望一步到位——我的代码是用CoffeeScript编写的,因此我还是在编译它

我试过什么? 除了无可救药地用谷歌搜索外,我还尝试使用以下AppleScript:

tell application "System Events"
   tell process "Safari"
       click the button "Reload" of window "Extension Builder"
   end tell
end tell
哪些错误与以下内容有关:

系统事件发生错误:无法获取进程“Safari”的窗口“扩展生成器”的按钮“重新加载”

这种变化:

tell application "System Events"
    tell process "Safari"
       tell button "Reload" of window "Extension Builder" to perform action
    end tell
end tell

这不会给出错误,但实际上也不会做任何事情。

可能是按钮没有如您所期望的那样“命名”。签出以查看应用程序的接口层次结构,以便与GUI脚本一起使用

可通过以下方式访问“重新加载”按钮:

click button "Reload"  of UI element "ReloadUninstall[NAME OF EXTENSION HERE]" \
  of UI element 1 of scroll area 1 of window "Extension Builder"

自编写接受的答案以来,扩展浏览器的视图层次结构似乎已更改。这个脚本适合我:

tell application "System Events"
    tell process "Safari"
         click button "Reload" of UI element 0 of window "Extension Builder"
    end tell
end tell
请注意,Safari和Extension Builder窗口需要打开才能正常工作