[python-win32] Control Volume on Windows [SEC=UNCLASSIFIED]

Andrew MacIntyre Andrew.MacIntyre at acma.gov.au
Wed Mar 12 00:24:32 CET 2014

>Trevor Haba wrote:
>> I'm looking for a way to use python to change the volume on windows.
>> After some googling the best I could come up with was this script I 
>> got from a relatively ancient entry on this mailing list (I think it 
>> was from 2005 or something). I'm using windows 7, and I would like it 
>> to work on windows 8 if possible, though its not necessary. I don't 
>> need to support any previous versions of windows.

To which Tim Roberts replied:
> Alas, the news is not good.
> The simple and easy-to-use winmm APIs are no longer supported.  They
> still work in many cases, but the mapping from the winmm device
> numbering to the new audio API device numbering is mysterious, as you
> have learned, and there is no good recipe to find them that works on
> every system.
> The "blessed" method of adjusting the volume in the Vista-and-beyond
> audio world requires the use of COM.  You fetch an IMMDeviceEnumerator
> interface, use that to fetch an IMMDevice for your device, then fetch an
> IAudioEndpoint interface and call SetMasterVolumeLevel to adjust the
> volume.  That's not really very much code in C++ terms, BUT none of those
> interfaces have late-binding support, which means Python cannot use them.

I think that comtypes (https://pypi.python.org/pypi/comtypes) can deal with early binding interfaces?

-------------------------> "These thoughts are mine alone!" <---------
Andrew MacIntyre           Operations and Services Branch
tel:   +61 2 6219 5356     Communications Infrastructure Division
fax:   +61 2 6219 5347     Australian Communications & Media Authority
email: andrew.macintyre at acma.gov.au            http://www.acma.gov.au/

NOTICE: This email message is for the sole use of the intended recipient(s) 
 and may contain confidential and privileged information. Any unauthorized 
 review, use, disclosure or distribution is prohibited. If you are not the 
 intended recipient, please contact the sender by reply email and destroy all 
 copies of the original message.

More information about the python-win32 mailing list