Skip to content

Instantly share code, notes, and snippets.

@deitrix
Last active July 7, 2026 12:55
Show Gist options
  • Select an option

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

Select an option

Save deitrix/ceb8254d927bd0330c3e2767f076b8ce to your computer and use it in GitHub Desktop.
#Requires AutoHotkey v2.0
#SingleInstance Force
; --- Configuration ---
global MouseDebounce := {
DebounceTime: 200, ; Minimum ms between allowed clicks
LastBackDown: 0,
LastForwardDown: 0
}
; --- 1. BACK BUTTON (XButton1) ---
*XButton1:: {
currentTick := A_TickCount
if (currentTick - MouseDebounce.LastBackDown < MouseDebounce.DebounceTime) {
; Optional feedback for debugging
ToolTip("Debounced (Back): " . (currentTick - MouseDebounce.LastBackDown) . "ms")
SetTimer () => ToolTip(), -1000
return
}
MouseDebounce.LastBackDown := currentTick
Click("Down X1")
}
*XButton1 Up:: {
if GetKeyState("XButton1")
Click("Up X1")
}
; --- 2. FORWARD BUTTON (XButton2) ---
*XButton2:: {
currentTick := A_TickCount
if (currentTick - MouseDebounce.LastForwardDown < MouseDebounce.DebounceTime) {
ToolTip("Debounced (Forward): " . (currentTick - MouseDebounce.LastForwardDown) . "ms")
SetTimer () => ToolTip(), -1000
return
}
MouseDebounce.LastForwardDown := currentTick
Click("Down X2")
}
*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