以下の内容はhttps://chamekichi.hatenadiary.jp/entry/2022/05/27/212716より取得しました。


Pycawを使ってWindowsのマスターボリュームをPythonから操作する

概要

Pycawのインストール

  • pip経由でPycawを落としてくる
pip install pycaw

使い方

  • 例:全てのアプリ(全てのSession)をMuteする
"""
Per session GetMute() SetMute() using ISimpleAudioVolume.
"""
from __future__ import print_function

from pycaw.pycaw import AudioUtilities, ISimpleAudioVolume


def main():
    sessions = AudioUtilities.GetAllSessions()
    for session in sessions:
        volume = session._ctl.QueryInterface(ISimpleAudioVolume)
        print("volume.GetMute(): %s" % volume.GetMute())
        volume.SetMute(1, None)


if __name__ == "__main__":
    main()

結果

  • 全てのアプリをMuteすることができた。
    windows volume

参考資料




以上の内容はhttps://chamekichi.hatenadiary.jp/entry/2022/05/27/212716より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14