2

特定のポップアップ メニューの項目のクリックを自動化したい。例えば、「メッセージ受信音」の値を別のものに変更したい。AppleScriptでこれを行うにはどうすればよいですか? また、AppleScript の他のポップダウン メニューでこれを行うにはどうすればよいですか?

(画像に示されている iMessage 設定メニューを開くには、iMessage を開いたら、CMD COMMA と入力します)

注: 私はこの Automator を正常に実行しました。AppleScript で実行したいだけです。

ここに画像の説明を入力

4

1 に答える 1

3

これは GUI スクリプトと呼ばれます。UI 要素への参照を識別する必要があります。

GUI スクリプトは、システムのバージョンに大きく依存します。更新によって UI 構造が変更されると、スクリプトは中断します。

これにより、サウンドポップアップメニューでサウンド「ポップコーン」が選択されます。エルキャピタン用です。10.11 より前のシステムでは、UI 要素が異なる可能性があり、プロセス名が「iChat」である可能性があります。

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
于 2016-04-11T13:42:33.617 に答える