How to Create a Hot Key to Change Sound Devices in System Preferences

Thank you. You have been more than helpful.

I will see if I can work through this slowly and carefully.

I understand how difficult this can be so maybe someone else will chip in. Failing that I’ll be back at my office next Tuesday, so if you’re still having problems do keep us posted! Good luck

:crossed_fingers:

1 Like

Just looked at the original macro.

In this action:

Change the content of the to field to the name of the device you want to control. Do that in each of your 2 new macros. What you put in there must match exactly what you see in your system preferences.

Hi, @Ken1. I’m the person the created and shared the macro. Sorry to hear that you are having a problem. (Thanks, @tiffle, for your troubleshooting efforts!)

I suspect I know the cause of the issue but I’m away from my Mac so I can’t confirm my suspicion. In the meantime, please try downloading the add-on macro that can be used to toggle between two settings.

Toggle Sound Outputs

In that macro you will need to enter two of your sound outputs. You can then set a hot key for run THAT macro. I suspect it will work. Do be careful entering the sound output values. It can be tricky if the items include an apostrophe.

When I return to my home, I’ll troubleshoot further. I think it will be a trivial fix.

1 Like

Hi _jims,

Thank you so much for reaching out.

I have now installed the Macro that you suggested: Toggle Sound Outputs

Unfortunately I can't make this do anything. I have activated it. Even pressing run doesn't do anything.

And I entered the two devices. They are:

Display Audio
SSL 2

They have no strange markings of any kind. They are straightforward.

I am running Monterey 12.6.5.

Here is a screenshot I'm getting an error when I try to invoke this new macro that you suggested I install. It can't seem to find it.

CleanShot 2023-05-06 at 17.58.000386

Here is the screenshot of the macro so you can see how I did it.

CleanShot 2023-05-06 at 18.04.000387

One more thing that might help. Here's a screenshot of my system preferences for audio so you can see how these things are spelled. They are very simple.

CleanShot 2023-05-06 at 18.21.000392

OK, I have shown here all that I can think of to show to help troubleshoot. I hope it is helpful.

Yes, I have done that and they are very simple. There is no weird spelling. Moreover, when I click play, both macros work. They worked flawlessly. It's only when I add a hot key that they start producing errors

Hi @Ken1. I've updated Set Sound Output to Version 5. Please do the following:

  1. Keep your current Set Sound Output macros, but rename them by adding a suffix of "- OLD".

  2. Delete the Toggle Sound Output macro you downloaded.

  3. Download and install Set Sound Output, Version 5.

  4. Open one of your "- OLD" macros and copy the local_SoundOutputName to the clipboard.

  5. From the Keyboard Maestro Editor, run Set Sound Output (Version 5.0). You will see a dialog that will prompt you for your Sound Output Name. Paste the value you copied to the clipboard.

  6. Click OK to dismiss the dialog. A simple macro will be created that executes Set Sound Output using the value you pasted. Optionally change the triggers.

  7. Repeat Steps 4 to 6 for all of your "- OLD" macros.

  8. Optionally download the latest version of Toggle Sound Output. Open it and set local_Sound Output Name 1 and local_Sound Output Name 2 as needed. Optionally change the macro triggers.

  9. Once you test the new macros, delete the macros you renamed in Step 1.


Please report back after completing the steps above.

1 Like

Hi _jims,

OK I just followed all instructions and it all works perfectly now. I don't know what kind of juju you do, but it is really spectacular.

I had first followed the first part of your instructions working with the Set Sound Output. This worked exactly as you said it should including being able to be triggered with a hotkey now with no problem.

Then I deleted the old macros with no problem.

Then I installed the: Toggle Sound Output. This works absolutely perfectly. One thing I like about it is I don't have to remember which setting it is already on. I just click it and it goes to the other one.

I think toggle sound output is the one I will continue to use unless you can think of a reason why I shouldn't.

Let me mention a couple of additional things.

  1. Now there is the new version of set sound output. It just is living in that folder. Here is a screenshot. Do I need to keep that there or is there any harm in keeping it there?

CleanShot 2023-05-07 at 08.44.000394

  1. I still have that floating panel. What would be the best way to shut that off. I don't need it?

  2. Occasionally, my system seems to change the Sound Input all by itself. I will be listening to the display audio and then I will jump on a zoom call. It will often change the sound input to display audio. It shouldn't do that it should pretty much always be on SSL 2. There are other times it changes as well and all of a sudden my audio sounds bad.

Is there an easy way that I could create a hot key that would just trigger the sound input to SSL 2? This doesn't need to change back-and-forth from one thing to another. I just need to occasionally trigger it to make sure it is still on: SSL 2.

I am really grateful for your help. This has been a thorn in my side for so long and yesterday I finally decided to see if I could figure out how to deal with it. Your programming really made this convenient and exactly what I was hoping for.

Hi, @Ken1. Glad it's working well for you now!

No, problem whatsoever, but now I've added some other possibilties that you might like. See below.

As you have it working now, you need to keep it (because the specific macros call Set Sound Input), but you could move it, but I would recommend that you leave them together.

I've been meaning to create Set Sound Input; your request got me moving. For more information, see:

And finally: Using 'Set Sound Output' and 'Set Sound Input' Together


@Ken1, if you have any additional questions, please let me know.

1 Like

OK, my level of inadequacy here is on full display.

Let me tell you what I did and maybe there is a really simple thing I missing. I'm sure there probably is.

I downloaded the new set sound output V6.0, double clicked it and it appears to be just fine.

When I run it, it creates a subroutine.

If I engage the macro it's still adjust the output but does not adjust the input.

I'm really sorry to be such a bother. If additional Screenshots would help, I would be happy to provide them. I simply don't know where to adjust anything in the new input settings.

Hi, @Ken1. Yes, this should be pretty easy to resolve.

To get an overview, I suggest you read this first: Using 'Set Sound Output' and 'Set Sound Input' Together

That's good! However, since you are having trouble and it's difficult to troubleshoot via the forum, I suggest you start from scratch by completing the following steps. In the long run, it won't take long and it will be worth it :grinning::

  1. Delete all of the Set Sound... macros and subroutines you have in the Keyboard Maestro library. This includes the macros you installed from the forum and the calling macros that were automatically created. (The one exception might be the Toggle macro, but even if you delete it, you can easily reinstall it later.)

  2. Confirm that all Set Sound... macros and subroutines are deleted by doing a global search of your macro library.

    • In the Keyboard Maestro Editor, press ⌥⌘F or select: Edit > Find > Find in All Macros...
    • In the Keyboard Maestro Editor Search field, located in the upper-right, type: name:"Set Sound"


  1. Download and install Set Sound Output.

  2. From the Keyboard Maestro Editor, execute Set Sound Output as many times as necessary to create a calling macro for each of your sound output devices. Optionally assign hot key triggers for any (or all) of the created calling macros.

  3. Download and install Set Sound Input.

  4. From the Keyboard Maestro Editor, execute Set Sound Input as many times as necessary to create a calling macro for each of your sound input devices. Optionally assign hot key triggers for any (or all) of the created calling macros.

  5. Now you can control your sound output and sound input independently.

  6. If you would like to control both with a single hot key trigger, you could copy one of the output calling macros and, in the copy, paste in the action from one of the input calling macros. For details, refer back to: Using 'Set Sound Output' and 'Set Sound Input' Together

  7. You could optionally create additional output/input combination calling macros.

Hi _Jims,

Once again, much success. I followed the instructions. I deleted everything that was there and start over. Now I have the following - all of which work.

I have two calling macros to set my sound output. One is for the sound card called SSL 2, and the other is for Display Audio. They each have a hot key assigned and work perfectly.

Here is a screenshot to show you.

I also have one calling macro to set my sound input to: SSL 2. It also works perfectly.

Here is a screenshot to show you as well.

I can now use a hot key to get either output selected. And I can use the hotkey to get the sound input that I always want selected, selected.

Thank you so much for all of this.

Try as I might I cannot see what too do to make them work together.

Best case scenario would be that I hit the hotkey for audio output: Display Audio, end it triggers as well the audio input called: SSL 2.

If possible, I would set up as well so that when I hit the hot key for Audio Output: SSL 2, it would also trigger the same Audio Input: SSL 2.

When I created the calling macros, they all have the run as subroutine selected.

Here is the screenshot again to show you.

If there is something simple you can share with me that would enable me to use both of the sound outputs to trigger the sound input, I would be grateful.

If not, at least I can do better than I could before.

Thank you again.

Try this one for that combination...

Download: Set Sound O-Display Audio I-SSL 2.kmmacros (29 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.3.1 (22E772610a)
  • Keyboard Maestro v10.2

And this one for that...

Download: Set Sound O-SSL 2 I-SSL 2.kmmacros (29 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.3.1 (22E772610a)
  • Keyboard Maestro v10.2


If the two macros work individually, you could assign a hot key for each or if you assign the same hot key you will see a Keyboard Maestro Conflict Palette and be able to select from the palette.

1 Like

Hi _jims,

This worked perfectly. The second time I put that macro I just changed it to call the display audio instead of the SSL 2.

This works as well as I had ever hoped. I had no idea it was so complex. I think Apple programming and me are not necessarily a good mix.

I very much appreciate your patience, your kindness and your expertise in this.

You have really inspired me to keep learning.

Thanks again.

1 Like

Hi, @Ken1,

Previously you mentioned that you liked the idea of toggling between sound settings. If you'd like to do that with your two combinations of Output/Input, you could use this macro.

Download: Toggle Sound Output and Input (@Ken1).kmmacros (11 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.3.1 (22E772610a)
  • Keyboard Maestro v10.2

If I would only want to choose / toggle btw 2 Output sources, would the script not be simpler?

So I wrote

Set Sound External Headphones (for Macro 1)

and

Set Sound Mac mini Speakers (for Macro 2)

The macro is firing, but something doesn't work. What could it be?

Any assistance will be much appreciated.

OmarKN

Hi _jims,

When I first tried it, it did make a change. Then it sends an error and cancels the macro.

Here is a screenshot so you can see.:

I'm using the two with the arrows, and they work really well.

@Ken1, clearly I'm confused regarding your macro requirements. Above I read...

After reading that, I uploaded two macros:

  • Set Sound O-Display Audio I-SSL 2
  • Set Sound O-SSL 2 I-SSL 2

But in your latest screenshot I see:

  • Set Sound O-Display Audio I-Display Audio
  • Set Sound O-Display Audio I-SSL 2

I set up the Toggle macro using my assumptions, which appear to have been incorrect.

If you want, you can try to change the Toggle macro to meet your requirements.

First set up this section to include the two Output/Input combinations you want:

Then move down in the macro and click on these entries and select the two matching macros:


Or alternatively, you can delete the Toggle macro and just continue to use the two macros that you say are working well for you.

Hope that helps!

I’m really sorry my ignorance is causing this problem.

Thank you for your guidance. Thank you for uploading the changes and for everything you’ve done to help me.

I’m sorry that this has been difficult. I’m extremely grateful for your help.

1 Like

Hi, @okn; yes, it would a little faster, but you'll still see the System Preferences (or System Settings) open. Here's what you can do:

  1. Download and install: Set Sound Output

  2. If you want to set a sound output to an explicit device, then run Set Sound Output from the Keyboard Maestro Editor. Do this for each of your devices. For more information, see the description above the download link or the comments within the macro.

  3. If you want to also be able to toggle between two devices (as you mentioned), then download and install: Toggle Sound Output

  4. Refer to the Toggle Sound Output header comment. You'll see that you'll need to enter the name of both output devices.

Feel free to follow-up with addition questions, @okn.