Created
September 7, 2026 15:53
-
-
Save dijikul/ae033872e5aadb1c30a2ff213d05c190 to your computer and use it in GitHub Desktop.
AutoHotkey Hold Left Click when Mouse4 Clicked
This file contains hidden or 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 | |
| #Requires AutoHotkey v2.0 | |
| toggle := false | |
| targetWindow := "" ; will store the window handle | |
| XButton2:: { | |
| global toggle, targetWindow | |
| toggle := !toggle | |
| if toggle { | |
| targetWindow := WinActive("A") ; get the active window handle | |
| Send("{LButton down}") | |
| SetTimer MonitorConditions, 50 ; check conditions every 50ms | |
| ;ToolTip "Hold click: ON" | |
| } else { | |
| StopClicker() | |
| } | |
| } | |
| MonitorConditions() { | |
| global toggle, targetWindow | |
| if !toggle | |
| return | |
| if !WinActive("ahk_id " targetWindow) || GetKeyState("LButton", "P") { | |
| StopClicker() | |
| } | |
| } | |
| StopClicker() { | |
| global toggle | |
| toggle := false | |
| Send("{LButton up}") | |
| SetTimer MonitorConditions, 0 | |
| ;ToolTip "Hold click: OFF" | |
| Sleep 100 | |
| ToolTip | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment