【问题标题】:How can I get a list of menu items with Applescript?如何使用 Applescript 获取菜单项列表?
【发布时间】:2019-08-27 05:07:34
【问题描述】:

有没有什么方法可以使用 AppleScript 获取菜单标题下的所有菜单项列表,例如 FileEdit

我发现了一些相关的问题,但没有确切的答案。谷歌也没有运气。

我正在尝试获取在 Photoshop 的 Window 菜单中打开了哪些文件的列表,并找出哪个有复选标记。

我想我可以通过使用“In Applescript, how can I find out if a menu item is selected/focused?”之类的东西和辅助功能检查器来完成第二部分,因为它有AXMenuItemMarkChar

【问题讨论】:

    标签: macos applescript


    【解决方案1】:

    我没有 Photoshop,但这适用于 Illustrator:

    activate application "Adobe Illustrator"
    tell application "System Events"
        tell process "Adobe Illustrator CS5.1"
            set xxx to name of every menu item of menu 1 of menu bar item "Window" of menu bar 1
        end tell
    end tell
    

    要获取属性,您可以使用:

    activate application "Adobe Illustrator"
    tell application "System Events"
        tell process "Adobe Illustrator CS5.1"
            set xxx to value of attribute "AXMenuItemMarkChar" of menu item "tools" of menu 1 of menu bar item "Window" of menu bar 1
        end tell
    end tell
    

    零场景:

    activate application "Adobe Illustrator"
    tell application "System Events"
        tell process "Adobe Illustrator CS5.1"
            set xxx to value of attribute "AXMenuItemMarkChar" of menu item "Brushes" of menu 1 of menu bar item "Window" of menu bar 1
            try
                xxx
            on error
                -- insert your code
                beep 2
            end try
        end tell
    end tell
    

    【讨论】:

    • 甜蜜。谢谢!现在正在研究如何检查它是否是nil :)
    猜你喜欢
    • 2012-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多