Skip to content

Instantly share code, notes, and snippets.

@ion1
Last active April 19, 2026 19:47
Show Gist options
  • Select an option

  • Save ion1/ecef69ff372690cbc328fd2fd18a7196 to your computer and use it in GitHub Desktop.

Select an option

Save ion1/ecef69ff372690cbc328fd2fd18a7196 to your computer and use it in GitHub Desktop.
Push-to-mute using AutoHotKey
#Requires AutoHotkey v2.0
#Warn
#SingleInstance
SetWorkingDir(A_ScriptDir)
Component := ""
Device := "Analogue 1 + 2"
IntendedState := 1
SetTimer(ApplyMute, 1000)
SetMute(State) {
global IntendedState
IntendedState := State
ApplyMute()
}
ApplyMute() {
global IntendedState
try {
OldState := SoundGetMute(Component, Device)
if (OldState == IntendedState) {
return
}
SoundSetMute(IntendedState, Component, Device)
if (IntendedState) {
SoundPlay("mute.wav")
} else {
SoundPlay("unmute.wav")
}
} catch {
}
}
KeyHandler(key, modifier) {
If GetKeyState(modifier) {
SetMute(1)
} Else {
SetMute(1)
KeyWait(key)
SetMute(0)
}
}
F13::
+F13::
{
KeyHandler("F13", "Shift")
return
}
Joy6::KeyHandler("Joy6", "Joy5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment