我的搜索引导我找到了 Pywin32,它应该能够静音/取消静音并检测其状态(在 Windows 10 上,使用 Python 3+)。我找到了一种使用 AutoHotkey 脚本的方法,但我正在寻找一种 pythonic 方法。
更具体地说,我对使用 Windows GUI 不感兴趣。 Pywin32 使用 Windows DLL 工作。
到目前为止,我可以通过调用 ahk 脚本来做到这一点:
在Python脚本中:
import subprocess
subprocess.call([ahkexe, ahkscript])
在 AutoHotkey 脚本中:
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
最佳答案
您可以通过悖论 ( https://github.com/Paradoxis/Windows-Sound-Manager ) 使用 Windows 声音管理器。
from sound import Sound
Sound.mute()
每次调用 Sound.mute()
都会打开或关闭静音。查看 main.py
以了解如何使用 setter 和 getter 方法。
关于python - 如何使用 pywin32 静音/取消静音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55399396/