Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Monitor changes in default audio device on Win 8.1?

If you have a question or need help, this is the place to be.
Post Reply
EpicCyndaquil
Posts: 7
Joined: Tue Jul 15, 2014 12:53 am

Monitor changes in default audio device on Win 8.1?

Post by EpicCyndaquil »

Sometimes I get distracted and leave my music player (MusicBee) running when I'm away from my computer. So I wanted to set up a task for if Musicbee is playing music and the default audio device is my headphones, Musicbee will stop when I go idle or lock the screen. Does anyone know how this could be done?
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Monitor changes in default audio device on Win 8.1?

Post by Sem;colon »

Hello EpicCyndaquil,

that's funny, I'm just about to write a plugin to do that (as well as changing the default audio device)
ATM I'm failing on catching the events from windows, I found some c++ code on MSDN which does exactly what I need http://msdn.microsoft.com/en-us/library ... s.85).aspx but I have no idea about c++ and how to transfer this to Python.
I mean, if I hab this c++ code working as a console application I could interface to this console application in Python, but I even fail on compiling a working console application from that code. :oops:
If you like my work, Image me a drink :wink:
EpicCyndaquil
Posts: 7
Joined: Tue Jul 15, 2014 12:53 am

Re: Monitor changes in default audio device on Win 8.1?

Post by EpicCyndaquil »

Glad to hear I'm not the only one interested, Sem;colon!

If I was to do this myself (and granted, it'd be rather inefficient), I'd probably try to use WMI. However, it doesn't seem like the sounddevice class has a method to detect if it's the default device or not. :(

I use a program called SoundSwitch to switch between two of my devices (speakers and headphones) manually at my desktop machine, depending on the task at hand, people around, etc. It's also written in C++, but this single cpp file seems to be the meat and potatoes. The author gives us a bit of an explanation on his blog.

Hopefully something I've linked helps - I don't really understand C++ either (though I do know python!) and I'm a bit too tired right now to really dig through some unfamiliar code. :)
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Monitor changes in default audio device on Win 8.1?

Post by Sem;colon »

I found this tool as well, but it doesn't help me as it doesn't use this "IMMDeviceEnumerator::RegisterEndpointNotificationCallback" which I need to trigger events properly... What I can do at the moment with my plugin is actively check if the default device changed, but to do that I call a (another) console application - and this sucks as EventGhost creates events every time I call this application. I need something that stays open and listens for events from the system, like the example on the MSDN page I can't get to work... I don't think it's even very difficult to get this running, if you not what you are doing. :wink:
If you like my work, Image me a drink :wink:
blaher
Experienced User
Posts: 487
Joined: Thu Nov 17, 2011 1:27 am

Re: Monitor changes in default audio device on Win 8.1?

Post by blaher »

Might not help but nircmd.exe does a good job of setting the default audio device:
Attachments
Capture.PNG
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Monitor changes in default audio device on Win 8.1?

Post by Sem;colon »

Hello Blaher,

thank you, but I know about that as well..
Same problem here, Nircmd doesn't catch the events from windows, also it's not open source.
If you like my work, Image me a drink :wink:
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Monitor changes in default audio device on Win 8.1?

Post by Sem;colon »

Done!

A friend helped me with the c++ stuff!

You can download the plugin here:
viewtopic.php?f=9&t=6213
If you like my work, Image me a drink :wink:
Post Reply