Implement muting of system sounds

This commit is contained in:
PhatPhuckDave
2024-07-21 19:49:47 +02:00
commit 9bb627d93a
2 changed files with 29 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
main.log

28
main.py Normal file
View File

@@ -0,0 +1,28 @@
from pycaw.pycaw import AudioUtilities
import time
def find_session(name):
sessions = AudioUtilities.GetAllSessions()
for session in sessions:
if name in session.DisplayName:
return session
return None
def main():
while True:
try:
system_sounds_session = find_session('@%SystemRoot%\System32\AudioSrv.Dll,-202')
if system_sounds_session:
system_sounds_session.SimpleAudioVolume.SetMasterVolume(0.01, None)
print("System Sounds session found and volume set to 1%")
else:
print("System Sounds session not found.")
except Exception as e:
print(f"An error occurred: {e}")
time.sleep(1)
if __name__ == "__main__":
main()