Skip to content

Instantly share code, notes, and snippets.

@natekford
Last active November 1, 2025 06:15
Show Gist options
  • Select an option

  • Save natekford/57eb77234172275b14953fa4e038505a to your computer and use it in GitHub Desktop.

Select an option

Save natekford/57eb77234172275b14953fa4e038505a to your computer and use it in GitHub Desktop.

Revisions

  1. natekford revised this gist Nov 1, 2025. 1 changed file with 27 additions and 12 deletions.
    39 changes: 27 additions & 12 deletions ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -3,27 +3,42 @@

    global MIC := "FIFINE T669"

    Notify(false)
    SetTray(SoundGetMute(, MIC))
    SetTimer(CheckExes, 1000)

    *F24::
    *F24::ToggleMuteAndNotify()
    *F23::SetMuteAndNotify(1)
    *F22::SetMuteAndNotify(0)

    SetMuteAndNotify(value)
    {
    isMuted := SoundGetMute(, MIC)

    SoundSetMute(value, , MIC)
    if (isMuted != value)
    {
    Notify(value)
    }
    }

    ToggleMuteAndNotify()
    {
    SoundSetMute(-1, , MIC)
    Notify(true)
    Notify(SoundGetMute(, MIC))
    }

    Notify(makeNoise)
    SetTray(isMuted)
    {
    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)
    }
    }

    Notify(isMuted)
    {
    SetTray(isMuted)
    SoundPlay(isMuted ? "C:\Windows\Media\Speech Off.wav" : "C:\Windows\Media\Speech On.wav")
    ToolTip(isMuted ? "MUTED" : "UNMUTED")
    SetTimer(() => ToolTip(), -1000)
    }

    CheckExes()
  2. natekford revised this gist Oct 31, 2025. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -37,22 +37,25 @@ CheckExes()

    for exe, isRunning in exes
    {
    if (!isRunning && WinExist("ahk_exe " . exe . ".exe"))
    ; exe currently running
    winExists := WinExist("ahk_exe " . exe . ".exe")
    if (!isRunning && winExists)
    {
    ; only restart if the exe is started after the script
    ; only reload if the exe is started after the script
    if (A_TickCount > ahk_start + 5000)
    {
    Log(exe " is now running. Reloading script")
    Reload()
    }
    ; if it's been running before the script, that's fine
    ; if it was running before the script, that's fine
    else
    {
    Log(exe " was running before script launched; not reloading script.")
    exes[exe] := true
    }
    }
    else if (isRunning)
    ; exe not running anymore, set back to false
    else if (isRunning && !winExists)
    {
    Log(exe " is no longer running.")
    exes[exe] := false
  3. natekford revised this gist Oct 31, 2025. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -37,23 +37,21 @@ CheckExes()

    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 && WinExist("ahk_exe " . exe . ".exe"))
    {
    if (!isRunning && A_TickCount > ahk_start + 5000)
    ; only restart if the exe is started after the script
    if (A_TickCount > ahk_start + 5000)
    {
    Log(exe " is now running. Reloading script")
    Reload()
    }
    else if (!isRunning)
    ; if it's been running before the script, that's fine
    else
    {
    Log(exe " was running before script launched; not reloading script.")
    exes[exe] := true
    }
    }
    ; exe not running anymore, set back to false
    else if (isRunning)
    {
    Log(exe " is no longer running.")
  4. natekford revised this gist Oct 31, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -47,7 +47,7 @@ CheckExes()
    Log(exe " is now running. Reloading script")
    Reload()
    }
    else
    else if (!isRunning)
    {
    Log(exe " was running before script launched; not reloading script.")
    exes[exe] := true
  5. natekford revised this gist Oct 31, 2025. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions ToggleMuteMicrophone.ahk
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,10 @@ CheckExes()
    {
    ; some games interfere with hotkeys until the script is restarted
    static ahk_start := A_TickCount
    static exes := Map("RDR2", false)
    static exes := Map(
    "RDR2", false,
    "Condemned", false
    )

    for exe, isRunning in exes
    {
    @@ -41,17 +44,25 @@ CheckExes()
    {
    if (!isRunning && A_TickCount > ahk_start + 5000)
    {
    Log(exe " is now running. Reloading script")
    Reload()
    }
    else
    {
    Log(exe " was running before script launched; not reloading script.")
    exes[exe] := true
    }
    }
    ; exe not running anymore, set back to false
    else
    else if (isRunning)
    {
    Log(exe " is no longer running.")
    exes[exe] := false
    }
    }
    }

    Log(text)
    {
    FileAppend(A_NowUTC ": " text "`n", "ToggleMuteMicrophone.log")
    }
  6. 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)
  7. 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)
    }
    }
  8. 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
    }
    }
    }