【问题标题】:Selecting Pop Up Menu Buttons in AppleScript在 AppleScript 中选择弹出菜单按钮
【发布时间】:2016-08-01 15:59:03
【问题描述】:

我想自动单击特定的弹出菜单项。 例如,我想将“消息接收声音”的值更改为其他值。如何使用 AppleScript 做到这一点?以及如何使用 AppleScript 中的其他弹出菜单执行此操作?

(要打开 iMessage 设置菜单,如图所示,在打开 iMessage 后键入 CMD COMMA)

注意:我已经成功完成了这个 Automator,我只想在 applescript 中完成。

【问题讨论】:

    标签: user-interface applescript imessage


    【解决方案1】:

    它被称为 GUI 脚本。您必须确定对 UI 元素的引用。

    GUI 脚本很大程度上取决于系统版本。如果更新更改了 UI 结构,脚本将停止。

    这会在声音弹出菜单中选择声音“爆米花”。这是给埃尔卡皮坦的。在系统

    tell application "System Events"
        tell process "Messages"
            set frontmost to true
            if not (exists (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")) then
                keystroke "," using command down
                repeat until exists (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")
                    delay 0.1
                end repeat
            end if
            tell (1st window whose value of attribute "AXIdentifier" is "MessagesPreferencesWindow")
                tell pop up button 4 of group 1
                    click
                    delay 0.2
                    click menu item "Popcorn" of menu 1
                end tell
            end tell
        end tell
    end tell
    

    【讨论】:

    • 如何确定菜单/按钮/组号?
    • 在调试时能够转储此类标识符会很好。不要敲击 UI 浏览器 - 我更喜欢它,但我发现它在弹出对话框时经常崩溃。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 2021-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多