Change lines to scroll while Shift key is held down? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Rok
Posts: 63
Joined: 11 Jan 2016, 08:50

Change lines to scroll while Shift key is held down?

Post by Rok » 10 Jun 2023, 15:28

Is it possible to change or reduce the lines to scroll with the mouse wheel only while the Shift key, for example, is held down, or else the lines to scroll go back to their current setting in Windows?

If so, what's the script to accomplish this, please? I don't know where to even begin something like this.

User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Change lines to scroll while Shift key is held down?  Topic is solved

Post by mikeyww » 10 Jun 2023, 20:44

Code: Select all

#Requires AutoHotkey v2.0
+WheelUp::
+WheelDown::Send '{' SubStr(ThisHotkey, 2) ' 5}'

Rok
Posts: 63
Joined: 11 Jan 2016, 08:50

Re: Change lines to scroll while Shift key is held down?

Post by Rok » 29 Jun 2023, 06:46

mikeyww wrote:
10 Jun 2023, 20:44

Code: Select all

#Requires AutoHotkey v2.0
+WheelUp::
+WheelDown::Send '{' SubStr(ThisHotkey, 2) ' 5}'
Thank you very much for this code, mikeyww. Works like a charm.

By the way, one of the reasons I had to ask is that there doesn't seem to be a reference doc page for the WheelDown and WheelUp commands that clarifies that Send "{WheelDown 5}" or Send "{WheelUp 10}" is a thing. Even pages that show up after a search, like the Click page, don't clarify this. So, it's probably going to be helpful if the reference material administrators add a page and/or examples that explain this somewhere that a user can find with a relevant search.


Rok
Posts: 63
Joined: 11 Jan 2016, 08:50

Re: Change lines to scroll while Shift key is held down?

Post by Rok » 29 Jun 2023, 09:46

mikeyww wrote:
29 Jun 2023, 07:26
Repeating or holding down a key
Oh, that is the repeat feature! I thought it was a feature unique to WheelDown and WheelUp to change the number of lines scrolled by the commands. :lol:

I've been guilty of forgetting about the key repeat feature (Click 2 is popular, I think) and one-dimensionally using only loop statements for repeating hotkeys. And I learned today from that reference page you linked that one might intentionally want to sometimes use loop statements instead of Send "{KeyName [Integer]}" if they wanted to simulate the "auto-repeat" driver/hardware behavior of physically holding down a key.

Thanks a lot for clarifying. If one sets up the lines scrolled to something low in the operating system's mouse settings, then one can certainly use such code to increase the scrolling speed while holding down a modifier key. Brilliant, even if I thought I wanted a different thing.

User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Change lines to scroll while Shift key is held down?

Post by mikeyww » 29 Jun 2023, 09:51

All good.

1. Click 2 is different, as this uses the parameter for the Click function, not the syntax for the Send function (though these can be combined).

2. One reason to use Loop instead of Send {... n} on some occasions is if there is a need to break the loop upon certain conditions. This cannot generally be done easily with Send {... n}.

Post Reply

Return to “Ask for Help (v2)”