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:
JavaScript
x
3
1
import subprocess
2
subprocess.call([ahkexe, ahkscript])
3
In the AutoHotkey script:
JavaScript
1
5
1
SoundGet, sound_mute, Master, mute
2
if sound_mute = On ; if the sound is muted
3
Send {Volume_Mute} ; press the "mute button" to unmute
4
SoundSet 30 ; set the sound level at 30
5
Advertisement
Answer
You can use the Windows Sound Manager by paradoxis (https://github.com/Paradoxis/Windows-Sound-Manager).
JavaScript
1
3
1
from sound import Sound
2
Sound.mute()
3
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.