Applescript-如何告诉应用程序打开特定的菜单项

Applescript-如何告诉应用程序打开特定的菜单项,applescript,automator,Applescript,Automator,这是我第一次尝试创建applescript 我想做的是创建一个apple脚本,然后分配一个自定义的快捷方式,以便在需要时启动它 我需要它来快速扩展Thunderbird的insert->HTML…菜单 我当前的applescript嵌套在automator工作流中,代码如下: on run {input, parameters} tell application "Thunderbird" activate tell application "Sys

这是我第一次尝试创建applescript

我想做的是创建一个apple脚本,然后分配一个自定义的快捷方式,以便在需要时启动它

我需要它来快速扩展Thunderbird的
insert->HTML…
菜单

我当前的applescript嵌套在automator工作流中,代码如下:

on run {input, parameters}
   tell application "Thunderbird"
        activate
            tell application "System Events"
                tell process "Thunderbird"
                     click menu item 6 of menu 1 of menu bar item "Insert" of menu bar 1
                end tell
            end tell
    end tell
 return input
end run
当我启动它时(向automator授予权限后),我得到的错误是:

语法错误:系统事件出错;无法获取菜单栏项 进程“Thunderbird”菜单栏1的“插入”

我认为问题是因为只有在thunderbird中打开“写入新消息”面板时,“插入”菜单才可用

所以我的问题是,我如何更改上面的脚本,使其不只是检查“Thunderbird”应用程序,而是检查“Thunderbird”和它自己的“write new message”面板是否打开

还有,可能是因为这个原因我犯了这个错误,还是我在applescript创作中犯了一些错误


非常感谢,请随时询问更多详细信息。

雷鸟词典中是否有任何内容可以为您指明打开的“新消息”窗口/文档/等的方向?是的,在主应用程序顶部菜单中:文件->新建->消息(或cmd+N),但每次我调用我的午餐快捷方式时,此脚本中的我都已经在“编写新消息”中了面板,因为我可能会先按“回复”…很抱歉,我没有Thunderbird,所以我无法给出最终解决方案,但目标是检查Thunderbird的前窗口,UI元素必须存在才能处于“编写新消息”状态。要检查是否存在,请在“try/end”try块中使用get。