topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 5:13 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: [REQUEST] Program to make an output audio device default when connected  (Read 8219 times)

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
It would be nice if someone made a program that has a list of output audio devices that were recently used by the OS and let the user select one to use as default when it is connected until it is disconnected, which then will have it use the previous used one as default, then repeat that process when the selected one is connected again.

HwapX

  • Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
I'm working on a prototype, but it uses a priority list, sets the default device to the first one connected, and updates it when connecting a new one or disconnecting.



Edit

I've done some experiments and reading the Windows documentation it seems that what you want is almost the default behavior.
https://learn.micros...roperty-in-windows-7

Here I set my speaker as default device, I plugged in my headphone and set it as default, when I remove my headphone Windows sets the speaker as default and when I plug in my headphone it sets it as default
« Last Edit: June 23, 2023, 08:50 AM by HwapX »

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
It doesn't work for me the last time I tried it in Windows 10.

HwapX

  • Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Alright, tomorrow I think I'll have something for you to try out.

What do you think about the "priority list"? Does it solves your problem?

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
It will if it sets the headphones as default when they are connected and then sets the speakers as default when the headphones are disconnected. By the way, others are also having this issue (take a look at https://answers.micr...b3-aa39-4b51821a6965 for one such example).

HwapX

  • Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
I'm having some problems pushing the code to Github, but if you want you can test the attached executable.



Edit

Published the source code at https://github.com/H...udioPriorityAdjuster
« Last Edit: July 01, 2023, 06:48 PM by HwapX, Reason: Updated repository link »

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
I think you should change the name of the repository if possible along with making a better Readme that explains what the program does so other people can find it and be able to test it themselves in order to let you know of any issues they have. Once I have a new pair of headphones, I will test it and let you know if it does what I want or not.

HwapX

  • Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Sure, the name of the repository is an acronym for Donation Coder Auto Default Audio Device, but I was pretty sleepy when I created it and named the executable Auto Default Audio Device Switcher. Anyway, if you have a better name suggestion, I can change the name of the repository.

About the repository description, I intend to write a better readme, but that's for next weekend, if I have some spare time.

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
Maybe Audio Priority Adjuster would be a better name for it. The repository name should be audiopriorityadjuster or aap if you end up using the name that I suggested.

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
1. It turns out that Windows 10 already does what I want. I will use this though to make sure that the audio switches properly.
2. Please add the options for having it be minimized to system tray when ran and running on boot in the system tray.
3. I take it that it is monitoring for connections and disconnections, which it then modifies the registry accordingly?

HwapX

  • Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
Maybe Audio Priority Adjuster would be a better name for it. The repository name should be audiopriorityadjuster or aap if you end up using the name that I suggested.
I renamed the repository to AudioPriorityAdjuster, the dc prefix is just to mark that the project is from DonationCoder. Soon I will push the changes that rename the project and executable as well.

1. It turns out that Windows 10 already does what I want. I will use this though to make sure that the audio switches properly.
That was what i observed on my test machine. Anyway I hope the program is useful in some way.

2. Please add the options for having it be minimized to system tray when ran and running on boot in the system tray.
Sure! i just need to find a  way to register the program to be run on startup with Administrative rights, the "common" way wont work if UAC is enabled.

3. I take it that it is monitoring for connections and disconnections, which it then modifies the registry accordingly?
It is monitoring for device changes using the following API, basically it register program to be notified of device changes.
And when the program starts or receive an notification it check the priority list and uses this undocumented API to set the default audio device.


Edit

Done, the new version can be found at releases page on Github https://github.com/H...ityAdjuster/releases
« Last Edit: July 01, 2023, 08:04 PM by HwapX »

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
There are more things I noticed:

1. The -tray option is actually the -hidden option.
2. The shortcut that is made should be named Audio Priority Adjuster.
3. The tooltip of its system tray icon should be named Audio Priority Adjuster.

HwapX

  • Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
I was traveling last week.
I made the necessary adjustments today.

https://github.com/H...ityAdjuster/releases

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
The tooltip, title and shortcut name are still not changed.

HwapX

  • Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 11
    • View Profile
    • Donate to Member
You are right about the tooltip, i changed the wrong place.

But the shortcut are correctly, see:
Screenshot_1.png[REQUEST] Program to make an output audio device default when connected

Try manually deleting it and recreating.

New version with the tooltip fixed: https://github.com/H...ityAdjuster/releases

Zero3K

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 300
    • View Profile
    • Donate to Member
Thanks for fixing it.