[System Settings]Accessibility系の値のOFF ONの場合の相違(サウンド出力の切り替え) Toggle sound device between two devices
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | #com.cocolog-nifty.quicktimer.icefloe |
004 | # AccessibilityがONとOFFではWindowの構造が違っている事がポイント |
005 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
006 | use AppleScript version "2.8" |
007 | use scripting additions |
008 | |
009 | tell application id "com.apple.systempreferences" |
010 | activate |
011 | set miniaturized of the settings window to false |
012 | end tell |
013 | |
014 | #wait systempreferences |
015 | repeat 10 times |
016 | tell application id "com.apple.systempreferences" |
017 | set boolFrontMost to frontmost as boolean |
018 | end tell |
019 | if boolFrontMost is true then |
020 | # one-second prayer after exit |
021 | delay 1 |
022 | exit repeat |
023 | else |
024 | tell application id "com.apple.systempreferences" to activate |
025 | delay 0.5 |
026 | end if |
027 | end repeat |
028 | |
029 | #set anchor |
030 | tell application id "com.apple.systempreferences" |
031 | reveal anchor "output" of pane id "com.apple.Sound-Settings.extension" |
032 | end tell |
033 | tell application id "com.apple.systempreferences" to activate |
034 | |
035 | #wait Accessibility |
036 | repeat 10 times |
037 | tell application id "com.apple.systempreferences" |
038 | activate |
039 | tell current pane |
040 | set strPaneID to id |
041 | end tell |
042 | end tell |
043 | if strPaneID is "com.apple.systempreferences.GeneralSettings" then |
044 | delay 0.5 |
045 | else if strPaneID is "com.apple.Sound-Settings.extension" then |
046 | exit repeat |
047 | end if |
048 | end repeat |
049 | |
050 | #wait Sound |
051 | repeat 10 times |
052 | tell application id "com.apple.systempreferences" |
053 | tell front window |
054 | set strWindowName to name |
055 | end tell |
056 | end tell |
057 | if strWindowName is "サウンド" then |
058 | exit repeat |
059 | else |
060 | delay 0.5 |
061 | end if |
062 | end repeat |
063 | (* |
064 | MacOS15 NOTE |
065 | アクセシビリティ機能がONのときのターゲット属性 |
066 | list 2 of splitter group 1 of list 1 of window "Sound" |
067 | |
068 | アクセシビリティ機能がOFFのときのターゲット属性 |
069 | group 2 of splitter group 1 of group 1 of window "Sound" |
070 | |
071 | *) |
072 | # system events |
073 | tell application id "com.apple.systempreferences" |
074 | activate |
075 | tell application "System Events" |
076 | tell process "System Settings" |
077 | #TYPE A |
078 | try |
079 | tell outline 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1 of window "サウンド" |
080 | repeat with itemNo from 1 to 2 by 1 |
081 | tell row itemNo |
082 | set recordProperties to properties |
083 | set boolSelect to selected of recordProperties |
084 | if boolSelect is false then |
085 | select |
086 | exit repeat |
087 | end if |
088 | end tell |
089 | end repeat |
090 | log "Done type A" |
091 | end tell |
092 | on error |
093 | #TYPE B |
094 | tell outline 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "サウンド" |
095 | repeat with itemNo from 1 to 2 by 1 |
096 | tell row itemNo |
097 | set recordProperties to properties |
098 | set boolSelect to selected of recordProperties |
099 | if boolSelect is false then |
100 | select |
101 | exit repeat |
102 | end if |
103 | end tell |
104 | end repeat |
105 | log "Done type B" |
106 | end tell |
107 | end try |
108 | end tell |
109 | # click |
110 | end tell |
111 | end tell |
AppleScriptで生成しました |
| 固定リンク
« [System Settings]Accessibility系の値のOFF ON(音声コントロール) Toggle voice control on and off | トップページ | 【メモ】Visual Studio Code(Mac版)で文字コードの操作を行ってはいけない理由 »
「Accessibility」カテゴリの記事
- システム設定 アクセシビリティのアンカーリスト(2024.10.22)
- [System Settings]Accessibility系の値のOFF ONの場合の相違(サウンド出力の切り替え) Toggle sound device between two devices(2024.10.21)
- [System Settings]Accessibility系の値のOFF ON(音声コントロール) Toggle voice control on and off(2024.10.21)
- [Muisc]Music用パネルアップデート (macOS14.4対応)(2024.03.08)
- [Muisc]Music用パネルアップデート(2023.10.14)