Last active
March 21, 2023 07:02
-
-
Save xmedeko/11814b21b31c14d785019bc2598139d9 to your computer and use it in GitHub Desktop.
AutoHotkey volume by Window key
This file contains 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.0- | |
#SingleInstance Force | |
DEFAULT_VOLUME := 30 | |
; Single press - mute, unmute. Double press - unmute and default volume. | |
#F1:: { | |
static winf1_presses := 0 | |
if winf1_presses > 0 { ; Timer already started. | |
winf1_presses += 1 | |
} else { ; Timer not started. | |
winf1_presses := 1 | |
SetTimer AfterTimout, -300 ; Wait for more presses within a 400 millisecond window. | |
} | |
AfterTimout() { | |
if winf1_presses = 1 { ; Single press | |
SoundSetMute -1 | |
} else if winf1_presses >= 2 { ; Double or more presses | |
SoundSetMute 0 | |
SoundSetVolume DEFAULT_VOLUME | |
} | |
winf1_presses := 0 ; Reset the count to prepare for the next series of presses | |
} | |
} | |
; Decrease volume | |
#F2:: SoundSetVolume "-5" | |
; Increase volume | |
#F3:: SoundSetVolume "+5" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment