I would like to change sound output device (like option-clicking the speaker icon in the menubar) via script, but NOT through UI scripting, e.g., launching the System Pref panel.
UPDATE: Using @Mateusz solution below, here is an Applescript that, when launched, will give you a popup to select the desired audio output device:
set devices to do shell script "/Applications/Audiodevice/audiodevice output list"
set answer to choose from list (paragraphs of devices) with title "Audio Output" with prompt "Select a device" without multiple selections allowed
if answer is false then return
do shell script "/Applications/Audiodevice/audiodevice output " & quoted form of item 1 of answer
(Note: you need to put the audiodevice
file in /Applications
)