Last active
November 1, 2025 06:15
-
-
Save natekford/57eb77234172275b14953fa4e038505a 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" | |
| ChangeStatusIcons(false) | |
| SetTimer(CheckExes, 1000) | |
| ; Pressing the Windows key by accident is annoying | |
| LWin::return | |
| ; The keyboard I have doesn't have a mute button (it does have FN+10 but I don't want to use 2 keys) | |
| Pause:: | |
| { | |
| Send("{Volume_Mute}") | |
| } | |
| *F24:: | |
| { | |
| SoundSetMute(-1, , MIC) | |
| SoundPlay("*-1") | |
| ChangeStatusIcons(true) | |
| } | |
| ChangeStatusIcons(showToolTip) | |
| { | |
| text := "" | |
| if (SoundGetMute(, MIC)) | |
| { | |
| SetScrollLockState(False) | |
| ; TraySetIcon(A_AhkPath, 3) ; 3 = not filled in AHK icon | |
| TraySetIcon("sndvolsso.dll", 12) ; 12 = not filled in W10 microphone | |
| text := "MUTED" | |
| } | |
| else | |
| { | |
| SetScrollLockState(True) | |
| ; TraySetIcon(A_AhkPath, 1) ; 1 = filled in AHK icon | |
| TraySetIcon("sndvolsso.dll", 13) ; 13 = filled in W10 microphone | |
| text := "UNMUTED" | |
| } | |
| if (showToolTip) | |
| { | |
| ToolTip(text) | |
| SetTimer(() => ToolTip(), -1000) | |
| } | |
| } | |
| CheckExes() | |
| { | |
| 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 | |
| ; since some games interfere with hotkeys until script restarted | |
| 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