There is a problem with my Apple Display that is attached to my MacBook Air so when I start the computer the Sound output is set to the MBA. I can reset it to the display but it reverts back to the laptop.
I tried created a macro to:
Open the System Preferences
Open the Sounds Panel
Select the Output tab
Change the output to Display Audio
Using the Move and Click mouse action but it doesn’t work consistently. Sometimes it changes the sound, other times not, other times the Display Panel is selected instead of Sound.
Is the mouse action the best one to use for this and if yes, it there a way to ensure consistent mouse clicks in the right position?
With Mouse Click actions, always remember that the screen must be as expected before the click action is executed, so you will often need a Pause (or better yet, Pause Until) action before the mouse click actions.
You can use the Open System Preference action to get directly to the Sound preference, then Pause Until the window title is correct, then click on the Output tab, then Pause an appropriate length of time, and then click on the desired entry.
I expect @ccstone will chime in with the AppleScript way to do this, and that would be better solution as the System Preferences application is very scriptable.
As for AppleScript I'm only seeing UI-Scripting-based solutions for this, and that's disappointing.
Google:
AppleScript Audio Output
More to my liking is a little Unix executable that might do the trick.
I install non-Apple Unix Executables in:
/usr/local/bin/
(In the Finder type Cmd-Shift-G and paste the path into the resulting Go-To-Folder sheet.)
I don't have enough audio options to test the syntax, so you're on your own.
If you can get the executable to work from the Terminal you can use an Execute Shell Script Action in Keyboard Maestro, and it will be waaay more efficient than the UI AppleScript method.