Applescript单击嵌套菜单项

时间:2013-12-19 12:12:35

标签: menu applescript

非常简单的问题,但我试图点击菜单中列表中的菜单项 - 即单击菜单中的“文本编码”会显示不同类型编码的列表。我想用applescript选择某种编码。这是我的尝试:

tell application "System Events" to tell process "iChm"
    click menu item "Text Encoding" of menu "View" of menu bar item "View" of menu bar 1
    click menu item 2 of last menu item
end tell

非常感谢!

2 个答案:

答案 0 :(得分:2)

tell application "System Events" to tell process "iChm"
    tell menu item "Text Encoding" of menu 1 of menu bar item "View" of menu bar 1
        click menu item 3 of menu 1
    end tell
end tell

对于某些菜单项,您需要先单击菜单栏项:

tell application "System Events" to tell (process 1 where it is frontmost)
    tell menu bar item 3 of menu bar 1
        click
        click menu item "Open Recent" of menu 1
    end tell
end tell

答案 1 :(得分:0)

我想知道你要点击的内容会很好。如果它是“Unicode(UTF-8)”项,请注意Unicode之后(可能是开发人员的类型o)两个空格:

"Unicode  (UTF-8)"
        ^^

所以,如果你这样做:

tell application "System Events"
    click menu item "Unicode  (UTF-8)" of menu "Text Encoding" of menu item "Text Encoding" of menu "View" of menu bar item "View" of menu bar 1 of application process "iChm"
end tell

......它会起作用。