-
-
Save pa-0/98ce5e67cf00738b4dadfc14024f0887 to your computer and use it in GitHub Desktop.
Toggle mute via Windows for a microphone using AHK v2.
This file contains hidden or 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
| #Requires AutoHotkey v2+ | |
| #SingleInstance Force | |
| global MIC := "FIFINE T669" | |
| Notify(false) | |
| SetTimer(CheckExes, 1000) | |
| *F24:: | |
| { | |
| SoundSetMute(-1, , MIC) | |
| Notify(true) | |
| } | |
| Notify(makeNoise) | |
| { | |
| isMuted := SoundGetMute(, MIC) | |
| ; 12 = not filled in W10 microphone, 13 = filled in W10 microphone | |
| TraySetIcon("sndvolsso.dll", isMuted ? 12 : 13) | |
| if (makeNoise) | |
| { | |
| SoundPlay(isMuted ? "C:\Windows\Media\Speech Off.wav" : "C:\Windows\Media\Speech On.wav") | |
| ToolTip(isMuted ? "MUTED" : "UNMUTED") | |
| SetTimer(() => ToolTip(), -1000) | |
| } | |
| } | |
| CheckExes() | |
| { | |
| ; some games interfere with hotkeys until the script is restarted | |
| static ahk_start := A_TickCount | |
| static exes := Map("RDR2", false) | |
| for exe, isRunning in exes | |
| { | |
| ; exe currently running | |
| ; if it's been running before the script, that's fine | |
| ; only restart if the exe is started after the script | |
| if (WinExist("ahk_exe " . exe . ".exe")) | |
| { | |
| if (!isRunning && A_TickCount > ahk_start + 5000) | |
| { | |
| Reload() | |
| } | |
| else | |
| { | |
| exes[exe] := true | |
| } | |
| } | |
| ; exe not running anymore, set back to false | |
| else | |
| { | |
| exes[exe] := false | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment