Skip to content

Instantly share code, notes, and snippets.

@deitrix
Last active December 30, 2025 21:14
Show Gist options
  • Select an option

  • Save deitrix/8be36689bebb65421d535efb73b7ae4e to your computer and use it in GitHub Desktop.

Select an option

Save deitrix/8be36689bebb65421d535efb73b7ae4e to your computer and use it in GitHub Desktop.
Volume and Twinkle Tray with mouse scroll
#Requires AutoHotkey v2.0
#SingleInstance Force
; --- Configuration ---
DebounceTime := 200
LastBackDown := 0
LastForwardDown := 0
; --- 1. BACK BUTTON (XButton1) - Volume ---
; Custom Combination: Hold Back + Scroll
XButton1 & WheelUp:: Send("{Volume_Up}")
XButton1 & WheelDown::Send("{Volume_Down}")
; Intercept the Down event to filter stutters
*XButton1:: {
global LastBackDown
currentTick := A_TickCount
if (currentTick - LastBackDown < DebounceTime) {
ToolTip("Debounced (Back Down): " . (currentTick - LastBackDown) . "ms")
SetTimer () => ToolTip(), -1000
return ; Block the stutter
}
LastBackDown := currentTick
Click("Down X1")
}
; Ensure the Up event always fires if the Down event was accepted
*XButton1 Up:: {
if GetKeyState("XButton1")
Click("Up X1")
}
; --- 2. FORWARD BUTTON (XButton2) - Brightness ---
; Custom Combination: Hold Forward + Scroll
XButton2 & WheelUp:: Send("#{Numpad9}")
XButton2 & WheelDown::Send("#{Numpad1}")
; Intercept the Down event to filter stutters
*XButton2:: {
global LastForwardDown
currentTick := A_TickCount
if (currentTick - LastForwardDown < DebounceTime) {
ToolTip("Debounced (Forward Down): " . (currentTick - LastForwardDown) . "ms")
SetTimer () => ToolTip(), -1000
return ; Block the stutter
}
LastForwardDown := currentTick
Click("Down X2")
}
; Ensure the Up event always fires if the Down event was accepted
*XButton2 Up:: {
if GetKeyState("XButton2")
Click("Up X2")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment