I have an AppleScript I used from within Filemaker Pro 19 to open the System Settings sound pane and set the input source. It has worked flawlessly until I upgraded to Sonoma 14.1.1. I am not sure where I am failing. Any help would be wonderful
here is script
–get input sources available from Sound Pane of System Preferences
tell application “System Settings”
–delay so that system preferences can load
activate
repeat while not (exists of pane id “com.apple.preference.sound”)
delay 0.1
end repeat
–open sound pane and select input tab
reveal anchor “input” of pane id “com.apple.preference.sound”
end tell
tell application “System Events” to tell process “System Preferences”
set frontmost to true
repeat until frontmost
delay 0.1
end repeat
set Sound_loc to my getLocalWindowName()
repeat until exists of text field 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window Sound_loc
delay 0.1
end repeat
set InputSource1 to (get value of text field 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window Sound_loc)
–Row 1 is always “Internal Microphone”
try
set InputSource2 to (get value of text field 1 of row 2 of table 1 of scroll area 1 of tab group 1 of window Sound_loc)
–Row 2, if it exists, is the just attached external microphone name
on error number -1719
–trap for error when no USB microphone attached
set InputSource2 to “External Mic not attached”
end try
end tell
– get Users choice of audio input
set userCanceled to false
try
activate me
set dialogResult to display dialog ¬
“Please select your input source” buttons {InputSource1, InputSource2, “Cancel”} ¬
default button “Cancel” cancel button ¬
“Cancel”
on error number -128
set userCanceled to true
end try
if userCanceled then
set InputChoice to “User cancelled.”
– statements to execute when user cancels
display notification InputChoice with title “Alert”
setFilemakerpro(InputChoice)
quit application “System Settings”
else if button returned of dialogResult is InputSource1 then
set InputChoice to InputSource1
– statements to process input source is InputSource1
SetInputChoice(InputChoice)
setFilemakerpro(InputChoice)
else if button returned of dialogResult is InputSource2 then
set InputChoice to InputSource2
– statements to process input source is InputSource2
if InputChoice is “External Mic not attached” then
display notification “There is no external microphone connected. Please connect one and try again later.” with title “Alert”
setFilemakerpro(InputChoice)
quit application “System Settings”
else
SetInputChoice(InputChoice)
setFilemakerpro(InputChoice)
end if
end if
on SetInputChoice(InputChoice)
tell application “System Settings”
reveal anchor “input” of pane id “com.apple.preference.sound”
end tell
tell application “System Events” to tell process “System Preferences”
set frontmost to true
set Sound_loc to my getLocalWindowName()
set InputSource1 to (get value of text field 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window Sound_loc)
–Row 1 is always “Internal Microphone”
if InputChoice is InputSource1 then
select text field 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window Sound_loc
– make sure ambient noise reduction is checked
–there is no ambient noise reduction in latest MacOs
–if (get value of checkbox 1 of tab group 1 of window Sound_loc) = 0 then
– the value of the checkbox is 0 if unchecked; 1 if checked
–click checkbox 1 of tab group 1 of window Sound_loc
–end if
else
select text field 1 of row 2 of table 1 of scroll area 1 of tab group 1 of window Sound_loc
–Row 2 is the external microphone
end if
end tell
tell application “System Settings”
if InputChoice is InputSource1 then
set volume input volume 100 without output muted – set to maximum for interanl microphone
else
set volume input volume 75 without output muted – set volume lower for external microphones
end if
(* other optional settings in sound pane
set volumeSettings to (get volume settings)
if (output muted of volumeSettings) then
display dialog “Volume: Muted”
else
set theVolume to (output volume of volumeSettings)
display dialog (("Volume: " & theVolume) as string)
end if
set volume alert volume 75
set volume input volume 50
set volume output volume 50
set volume without output muted
get volume settings
*)
end tell
quit application “System Settings”
end SetInputChoice
on setFilemakerpro(InputChoice)
tell application “FileMaker Pro”
tell table “Preferences”
tell record 1
set cell “recordoptions1” to InputChoice --let Filemaker pro know which input to use
end tell
end tell
end tell
end setFilemakerpro
–allows user independent window location
on getLocalWindowName()
set p2pane to (path to library folder from system domain as text) & “PreferencePanes:Sound.prefPane:”
return localized string “CFBundleName” from table “InfoPlist” in bundle (p2pane as «class furl»)
end getLocalWindowName