TomiBelan / mute-on-focus-lost

Mute app on focus lost (AutoHotkey script)
9 stars 1 forks source link

Mute on focus lost

This script can automatically mute playing audio for an application when it loses focus, and unmute it when it regains focus. The feature is sometimes also known as "mute in background", "mute when inactive", "mute on minimize", or "mute on Alt+Tab".

For example, this is useful for games if you need to Alt+Tab out of the game and watch a video, but the game sounds keep playing. Some games have a built in "mute on focus lost" option, but this script should work for apps and games that don't.

Press Win+F1 to mute/unmute the active app right now.

Press Win+F2 to enable "mute on focus lost" mode for the active app. A short beep will let you know it worked. In this mode, the app will mute when you minimize it or switch to another window, and unmute when you switch back. Pressing the key again will disable "mute on focus lost" mode for this app and play a lower beep.

How to install it

Step 1: Download AutoHotkey. You will see two buttons. First, click "Download v2.0" and install it. Second, click "Download v1.1 (deprecated)" and install it.

Notes about AutoHotkey - This script only needs AutoHotkey v2, but most other scripts usually need v1, so it's safest to get both. - I prefer to install v2 first, but [either way should work](https://www.autohotkey.com/docs/v2/Program.htm#install_v1). - Personally, I like to install Windows software with [Chocolatey](https://community.chocolatey.org/), but at the moment their autohotkey.install package is still v1.

Step 2: Download this script. Find the "Code" button on top of this GitHub page and choose "Download ZIP". Extract the zip file somewhere. (Or if you prefer, you can clone it with Git.)

Step 3: Double click the mute_on_focus_lost.ahk file. It should show a system tray icon.

Step 4: (optional) To run the script automatically after reboot, create a shortcut in the "Startup" folder. Open the "Startup" folder by pressing Win+R and typing shell:startup. Holding the Alt key, drag and drop the .ahk file to the "Startup" window. (It should say "Create link in Startup" while dragging.)

Settings

If you want, you can change some settings by opening mute_on_focus_lost.ahk in Notepad.

After you save the file, run it again to load the new version.

Credits

Thanks!

Similar software