Implement muting of system sounds
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
main.log
|
28
main.py
Normal file
28
main.py
Normal 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()
|
Reference in New Issue
Block a user