在Applescript中,我试图激活Seamonkey中的菜单项

问题描述

|| 我是Applescript的新手。我已经进行了一些搜索和阅读,发现应该可以激活菜单项:
on do_menu(app_name,menu_name,menu_item)
    try
        -- bring the target application to the front
        tell application app_name
            activate
        end tell
        tell application \"System Events\"
            tell process app_name
                tell menu bar 1
                    tell menu bar item menu_name
                        tell menu menu_name
                            click menu item menu_item
                        end tell
                    end tell
                end tell
            end tell
        end tell
        return true
    on error error_message
        return false
    end try
end do_menu

-- In my case I want to start Seamonkey and open the Composer window (and select it) so I
-- do:
do_menu(\"SeaMonkey\",\"Windows\",\"Composer\")
当我运行该事件日志窗口时显示
tell application \"SeaMonkey\"
    activate
end tell
tell application \"System Events\"
    click menu item \"Composer\" of menu \"Windows\" of menu bar item \"Windows\" of menu bar 1 of process \"SeaMonkey\"
        --> error number -1728 from «class mbri» \"Windows\" of «class mbar» 1 of «class prcs» \"SeaMonkey\"
end tell
结果: 假 我看不到我在做什么错。     

解决方法

错误号-1728在AppleScript中似乎是一个通用的“未找到”错误。我在SeaMonkey中没有看到Windows菜单,但是却看到了Window菜单。尝试从Windows删除\“ s \”。 另外,我认为您可能需要启用“对辅助设备的访问”才能使“单击”工作,如果需要,您会收到一条错误消息。     ,@mu太短是否正确。从\'Windows \'中删除\'s \',它将起作用。如果您不想使用处理程序,这是精简版本。
activate application \"SeaMonkey\"
tell application \"System Events\"
    tell process \"SeaMonkey\"
        click menu item \"Composer\" of menu 1 of menu bar item \"Window\" of menu bar 1
    end tell
end tell