display dialog "Sounddevice" buttons {"Anlage", "Lautsprecher", "Abbrechen"} default button 2 with icon 2
if button returned of result is "Anlage" then
tell application "System Preferences" to activate
tell application "System Events"
tell process "System Preferences"
click menu item "Ton" of menu "Einstellungen" of menu bar 1
delay 2
set devices to every row of table 1 of scroll area 1 of ¬
tab group 1 of window "Ton"
set the_devices to {} as list
repeat with a_device in devices
if (value of text field 1 of a_device as text) ¬
is equal to "MD-PORT AN1" then
set selected of a_device to true
exit repeat
end if
end repeat
end tell
end tell
tell application "System Preferences" to quit
else if button returned of result is "Lautsprecher" then
tell application "System Preferences" to activate
tell application "System Events"
tell process "System Preferences"
click menu item "Ton" of menu "Einstellungen" of menu bar 1
delay 2
set devices to every row of table 1 of scroll area 1 of ¬
tab group 1 of window "Ton"
set the_devices to {} as list
repeat with a_device in devices
if (value of text field 1 of a_device as text) ¬
is equal to "Interne Lautsprecher" then
set selected of a_device to true
exit repeat
end if
end repeat
end tell
end tell
tell application "System Preferences" to quit
end if