Skip to content

Instantly share code, notes, and snippets.

@pa-0
Forked from natekford/ToggleMuteMicrophone.ahk
Created October 12, 2025 01:12
Show Gist options
  • Save pa-0/98ce5e67cf00738b4dadfc14024f0887 to your computer and use it in GitHub Desktop.
Save pa-0/98ce5e67cf00738b4dadfc14024f0887 to your computer and use it in GitHub Desktop.

Revisions

  1. @natekford natekford revised this gist Sep 6, 2025. 1 changed file with 8 additions and 17 deletions.
    25 changes: 8 additions & 17 deletions ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -3,40 +3,32 @@

    global MIC := "FIFINE T669"

    Notify(true)
    Notify(false)
    SetTimer(CheckExes, 1000)

    *F24::
    {
    SoundSetMute(-1, , MIC)
    Notify(false)
    Notify(true)
    }

    Notify(isStartup)
    Notify(makeNoise)
    {
    isMuted := SoundGetMute(, MIC)
    if (isMuted)
    {
    TraySetIcon("sndvolsso.dll", 12) ; 12 = not filled in W10 microphone
    }
    else
    {
    TraySetIcon("sndvolsso.dll", 13) ; 13 = filled in W10 microphone
    }
    ; 12 = not filled in W10 microphone, 13 = filled in W10 microphone
    TraySetIcon("sndvolsso.dll", isMuted ? 12 : 13)

    if (!isStartup)
    if (makeNoise)
    {
    if (!isMuted)
    {
    SoundPlay("*-1")
    }
    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)

    @@ -45,7 +37,6 @@ CheckExes()
    ; 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)
  2. @natekford natekford revised this gist Sep 6, 2025. 1 changed file with 12 additions and 24 deletions.
    36 changes: 12 additions & 24 deletions ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -3,46 +3,34 @@

    global MIC := "FIFINE T669"

    ChangeStatusIcons(false)
    Notify(true)
    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)
    SoundSetMute(-1, , MIC)
    Notify(false)
    }

    ChangeStatusIcons(showToolTip)
    Notify(isStartup)
    {
    text := ""
    if (SoundGetMute(, MIC))
    isMuted := SoundGetMute(, MIC)
    if (isMuted)
    {
    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)
    if (!isStartup)
    {
    ToolTip(text)
    if (!isMuted)
    {
    SoundPlay("*-1")
    }
    ToolTip(isMuted ? "MUTED" : "UNMUTED")
    SetTimer(() => ToolTip(), -1000)
    }
    }
  3. @natekford natekford created this gist Feb 9, 2025.
    78 changes: 78 additions & 0 deletions ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    #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
    }
    }
    }