Page 1 of 1

Can AHK change audio device settings...?

Posted: 03 Dec 2013, 23:41
by Coldblackice
Does AHK have the ability to change audio device settings in Windows? (Windows 7 Ultimate x64)

Specifically, I'm trying to automate the ability to change "Speaker Configuration" and "Default Format" in the Windows Sound control panel (because Windows keeps resetting my speakers to Stereo-2.1 and format to 16bit/44k).

Re: Can AHK change audio device settings...?

Posted: 05 Dec 2013, 11:27
by tank
seems the registry is different for each audio device so i cant offer a generic answer. but if you can isolate the registry entries and correct values you can use

Code: Select all

RegWrite, ValueType, RootKey, SubKey , ValueName, Value
to edit the setting.

Re: Can AHK change audio device settings...?

Posted: 21 Apr 2014, 20:31
by bidomo
I'm facing the same problem, i want to be able to switch between my Headset and my Speakers, setting the headset as default...

So far, only way to do is either manually, or devcon, don't know if nircmd setting the default audio device will work the same as enabling disabling it.

Manually, is a pain in the arse
Devcon can only disable the hardware completely, not only the output
nircmd, don't really know how it behaves

we should probably be able to sent command line parameters to mmsys.cpl so we can disable the 1st device, so the speakers may can play the sound, and re-enable to get audio on the headset, as turning it off doesn't help at all, only unplugging or disabling the output / hardware does the trick...

If anyone has any insight on the matter, help will be appreciated...

Re: Can AHK change audio device settings...?

Posted: 21 Apr 2014, 21:42
by Coldblackice
The problem, so far as I'm dealing with, is that "new" devices are created when certain monitor types are turned off/on (i.e., HDMI + DisplayPort). So I'm unable to do much with the registry, short of some type of "relative" adjustments rather than absolute -- e.g., "Lock the first subkey from ever changing" (assuming the "new" monitors' keys are always piled on from the same direction).

Thus, I think the way to do it might be through a quasi-"manual" activation, where AHK is essentially navigating through the Audio Settings dialogs -- but ideally able to do so without the GUI interface being used. Anyone know if this is doable via command line? That'd be fantastic if audio devices could be configured/switched/adjusted via commandprompt!

Re: Can AHK change audio device settings...?

Posted: 22 Apr 2014, 11:14
by bidomo
Coldblackice wrote: Thus, I think the way to do it might be through a quasi-"manual" activation, where AHK is essentially navigating through the Audio Settings dialogs -- but ideally able to do so without the GUI interface being used. Anyone know if this is doable via command line? That'd be fantastic if audio devices could be configured/switched/adjusted via commandprompt!
That's what i was thinking, back in the Win98 days, there was a lot of knowledge about dll calls to execute commands (like a shutdown, volume up, and stuff like that), it occurs to me, maybe there's a way to do something similar with control panel applets.

I tried to capture windows messages, but there's no way to lock into this applets (cannot find parrent window or something like that).

Re: Can AHK change audio device settings...?

Posted: 22 Apr 2014, 13:32
by dsdsds12
nircmd definitely works, I can vouch for for that, like I said here (I don't know how people missed my post) and when I use devcon it asks for reboot so it's not an option. like said in my post even nircmd method isn't fully foolproof :( it just changes the default audio device if anyone wants I can post a full procedure :)

Re: Can AHK change audio device settings...?

Posted: 22 Apr 2014, 17:16
by bidomo
dsdsds12 wrote:nircmd definitely works, I can vouch for for that, like I said here (I don't know how people missed my post) and when I use devcon it asks for reboot so it's not an option. like said in my post even nircmd method isn't fully foolproof :( it just changes the default audio device if anyone wants I can post a full procedure :)
I noticed nircmd, problem is, last time i tried, you had to restart your programs for the audio to be effectively channeled through the correct device, disabling my headset in the Soun / Playback Properties does not, only if the program requeres exclusive access, like a videogame...

I will try again.

Re: Can AHK change audio device settings...?

Posted: 22 Apr 2014, 19:50
by geek
The Vista Audio library is very relevant to this discussion
http://www.autohotkey.com/board/topic/2 ... functions/

Re: Can AHK change audio device settings...?

Posted: 23 Apr 2014, 19:49
by timeFlies
In particular, this post.

Re: Can AHK change audio device settings...?

Posted: 24 Apr 2014, 05:51
by dsdsds12
each and every one of those programs, scripts etc will only allow us to switch default audio device but, what we want is to disable one of those device like a said in my previous post. I've been googling for weeks now, I justcouldn't understand why isn't there is a script for something as simple as this :(
au.jpg

Re: Can AHK change audio device settings...?

Posted: 24 Apr 2014, 08:28
by tank
http://go4answers.webhost4life.com/Exam ... 25844.aspx
answer 4 is correct for the registry but it seems you have to be admin and might need to start and stop some service

Re: Can AHK change audio device settings...?

Posted: 24 Apr 2014, 19:33
by timeFlies
Try this. I'm not sure if it will work. I can't try because I'm on my mobile.

(Chaz is my name on the other forum.)

Edit: Nope, doesn't work.

Re: Can AHK change audio device settings...?

Posted: 26 Apr 2014, 12:19
by dsdsds12
@tank so there is no way via AHK
@timeFlies any attempt to disable a device via device manager requires a reboot :(

Re: Can AHK change audio device settings...?

Posted: 27 Apr 2014, 21:59
by tank
That isnt what i said at all but if your unable to explore the suggestion it may be just as true

Re: Can AHK change audio device settings...?

Posted: 28 Apr 2014, 00:58
by Coldblackice
What about changing a device's number of channels/speakers? The links posted so far have been helpful, but I still have yet to find anything pointing to how to accomplish this. Any ideas?