What I need
I'm looking for a tool or a script that allows me to access the Windows volume levels from the command line. Ideally it would allow me to get and set all volumes including application levels, but I'd settle for only getting, and only the master level. I don't mind if it uses
.Net, Voodoo, or butterflies. Any solution that will just give me a number that I can further process to fit a range from 0% to 100% will do.
Put another way, the prompt parts are the black box that I need filled:
C:\> getvol master 50
C:\> wmic <alias> where "device='master' and name='volume'" get name,value Name Value Volume 0xDEADBEEF
I don't mind if I have to spend some time to wrap it or even write something myself if the tools to do so are freely available. In the latter case, I'd need some pointers/proof-of-concept for the core, but I can manage the cruft on my own. Also I'd like to avoid installing new development frameworks just for this purpose (note that both music2myear's and iglvzx's answers were given before I introduced these requirements).
As "platforms", I have available:
- anything that comes with Windows 7 Home Premium
- anything that comes with Cygwin
Generally, open-source solutions are greatly preferred. Closed-source tools are ok as long as they're freeware and the source can be trusted. Commercial solutions are no-go.
What I don't need
- There are a few similar questions that mostly deal with setting the volume. Most of all, I need to get the volume, not set.
- There is
nircmdc, which supports setting volume, but not getting.
- There is a key in my registry that has values that change predictably when I adjust the volume via the GUI mixer, but I'd guess reading from that key is prone to breakage on hardware changes or system upgrades. Unless I can rely on the solution being reasonably future-proof, I can't use it.
- There are
WSHsolutions for setting the volume on the Web, but a) they too are only good for setting and, worse, b) they use
SendKeysor automated mouse movement to control the GUI. Automating the GUI is not an option.
##windows channel on freenode is unhelpful as ever, Google overflows with hacks and half-baked workarounds, and I can't tell a WinAPI call from a Wiccan incantation.
Does anyone know of a way?