My searches lead me to the Pywin32 which should be able to mute/unmute the sound and detect its state (on Windows 10, using Python 3+). I found a way using an AutoHotkey script, but I’m looking for a pythonic way.
More specifically, I’m not interested in playing with the Windows GUI. Pywin32 works using a Windows DLL.
so far, I am able to do it by calling an ahk script:
In the python script:
import subprocess subprocess.call([ahkexe, ahkscript])
In the AutoHotkey script:
SoundGet, sound_mute, Master, mute if sound_mute = On ; if the sound is muted Send {Volume_Mute} ; press the "mute button" to unmute SoundSet 30 ; set the sound level at 30
Advertisement
Answer
You can use the Windows Sound Manager by paradoxis (https://github.com/Paradoxis/Windows-Sound-Manager).
from sound import Sound Sound.mute()
Every call to Sound.mute()
will toggle mute on or off. Have a look at the main.py
to see how to use the setter and getter methods.