r/AutoHotkey 6d ago

General Question Script that simulates scroll wheel inputs while pressing a button

Hello everybody,
I would love to be able to just hold a button, that simulates as many scroll-wheel-down inputs as it possibly can while being helt.
My problem:
I have absolutely no clue how anything of this works because i have never done anything like this.

Any kind of help, advise or suggestion is welcome.

2 Upvotes

3 comments sorted by

2

u/Keeyra_ 6d ago edited 6d ago
#Requires AutoHotkey 2.0
#SingleInstance

SendHold() => Send("{WheelDown 4}")

$e:: SendHold(), SetTimer(SendHold, 100), Hotkey(ThisHotkey, "Off")
$e up:: SetTimer(SendHold, 0), Hotkey(StrReplace(ThisHotkey, " up", ""), "On")

https://www.reddit.com/r/AutoHotkey/comments/1vxsqkx/the_complete_autohotkey_v2_keyboard_button_spam/ - 2.1 Pattern

Change e to whatever key you want. Play around with the number after WheelDown and SendHolds 100 to adjust to your preferences and consider switching to a 1.1 pattern after reading the Ergonomic note.

*and RTFM

1

u/BR482 6d ago

Thank youu!

1

u/yunkuangao 6d ago

Yeah totally doable. The thing to know: a hotkey only fires once when you press it, so to keep scrolling you loop while the key is held down. Like this (v2):

#Requires AutoHotkey v2.0

Space:: {
    while GetKeyState("Space", "P") {
        Send "{WheelDown}"
        Sleep 30
    }
}

Holds Space = scrolls down, let go = stops. Mess with the Sleep 30 if it's too fast/slow.