2016-03-30 7 views
1

私はこのプラクティスヘッドセットにオーディオ入出力を設定するこのスクリプトを持っていますが、デバイスがプラグインされていないとエラーになります。私はそれはそれはオーディオの設定内で検出されていない場合デバイスが存在する場合AppleScriptのオーディオ入出力セット

「でデバイスをプラグイン」

を言って、テキストを返す必要があります。ここで

はスクリプトです:

tell application "System Preferences" to activate 
tell application "System Preferences" 
    reveal anchor "input" of pane id "com.apple.preference.sound" 
end tell 
tell application "System Events" to tell process "System Preferences" 
    tell table 1 of scroll area 1 of tab group 1 of window 1 
     select (row 1 where value of text field 1 is "Plantronics C725") 
    end tell 
end tell 
tell application "System Preferences" to activate 
tell application "System Preferences" 
    reveal anchor "output" of pane id "com.apple.preference.sound" 
end tell 
tell application "System Events" to tell process "System Preferences" 
    tell table 1 of scroll area 1 of tab group 1 of window 1 
     select (row 1 where value of text field 1 is "Plantronics C725") 
    end tell 
end tell 

答えて

1

あなたが "選択..." のtry /最後のtryブロックにあなたの命令を含める必要があります。 「入力」がOKであれば、ヘッドセットが接続され、出力タブもOKでなければならないので、「入力」タブのためにそれを行う必要があると仮定します。

命令に置き換えますが、あなたはまた、エラーの場合に繰り返すようにコードを変更することができますが、あなたは、ヘッドセットに問題がある場合は

try 
select (row 1 where value of text field 1 is "Plantronics C725") 
on error 
display alert "headset not connected !" 
return 
end try 

スクリプトを者:

select (row 1 where value of text field 1 is "Plantronics C725") 

を永遠に繰り返す!

関連する問題