This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code is licensed under the terms of the MIT license | |
# This script is made to force some Windows app to stop outputting sound when not focused. | |
# Requirements: - Windows operating system (tested on Windows 10 22H2) | |
# - python 3 | |
# - pycaw (Python Core Audio Windows Library): `pip install pycaw` | |
# Acknowledgments: | |
# - Most of the credit goes to superuser.com user steve0: https://superuser.com/a/1796210 | |
# - Refactoring and improved UX by stduhpf, with the help of a local llama-3 8B (4bit) instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class SoundPlayer { | |
[DllImport("winmm.dll")] | |
public static extern bool PlaySound(string pszSound, IntPtr hmod, uint fdwSound); | |
} | |
"@ | |
# You can change the path to any wav file you want to play |