Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
461 B
1
Indexable
Never
import win32gui, time, winsound
from pycaw.pycaw import AudioUtilities, ISimpleAudioVolume

w=win32gui
sessions = AudioUtilities.GetAllSessions()

while True:
    for session in sessions:
        volume = session._ctl.QueryInterface(ISimpleAudioVolume)
        volume.SetMasterVolume(1, None)

    winText = w.GetWindowText (w.GetForegroundWindow())

    if "code" not in winText.lower():
        winsound.Beep(800, 200)

    print(winText)
    time.sleep(0.5)