1from ctypes import cast, POINTER
2from comtypes import CLSCTX_ALL
3from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
4devices = AudioUtilities.GetSpeakers()
5interface = devices.Activate(
6 IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
7volume = cast(interface, POINTER(IAudioEndpointVolume))
8volume.GetMute()
9volume.GetMasterVolumeLevel()
10volume.GetVolumeRange()
11volume.SetMasterVolumeLevel(-20.0, None)