« sudo のログを取得する(macOS15以降用) | トップページ | [System Settings]Accessibility系の値のOFF ONの場合の相違(サウンド出力の切り替え) Toggle sound device between two devices »

[System Settings]Accessibility系の値のOFF ON(音声コントロール) Toggle voice control on and off


AppleScript サンプルコード

【スクリプトエディタで開く】 |

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
006use AppleScript version "2.8"
007use scripting additions
008
009tell application id "com.apple.systempreferences"
010  activate
011  set miniaturized of the settings window to false
012end tell
013
014#wait systempreferences
015repeat 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
027end repeat
028
029#set anchor
030tell application id "com.apple.systempreferences"
031  reveal anchor "AX_VOICE_CONTROL_ENABLED" of pane id "com.apple.Accessibility-Settings.extension"
032end tell
033tell application id "com.apple.systempreferences" to activate
034
035#wait Accessibility
036repeat 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 "pane com.apple.Accessibility-Settings.extension" then
046    exit repeat
047  end if
048end repeat
049
050#wait Voice Control
051repeat 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
062end repeat
063
064# system events
065tell application id "com.apple.systempreferences"
066  activate
067  tell application "System Events"
068    tell process "System Settings"
069      (*
070OS15 note
071アクセシビリティ機能がOFFのときのターゲット属性
072group 2 of splitter group 1 of group 1 of window "Voice Control"
073アクセシビリティ機能がONのときのターゲット属性
074list 2 of splitter group 1 of list 1 of window "Voice Control"
075    *)
076      try
077        # OFF to ON
078        select checkbox 1 of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "音声コントロール"
079        click checkbox 1 of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "音声コントロール"
080        log "Done type A"
081      on error
082        #ON to OFF
083        select checkbox 1 of group 1 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1 of window "音声コントロール"
084        click checkbox 1 of group 1 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1 of window "音声コントロール"
085        log "Done type B"
086      end try
087      
088    end tell
089  end tell
090end tell
AppleScriptで生成しました

|

« sudo のログを取得する(macOS15以降用) | トップページ | [System Settings]Accessibility系の値のOFF ONの場合の相違(サウンド出力の切り替え) Toggle sound device between two devices »

Accessibility」カテゴリの記事