Accelerated horizontal scrolling Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Zek
Posts: 2
Joined: 06 Jul 2022, 14:06

Accelerated horizontal scrolling

Post by Zek » 06 Jul 2022, 14:21

Hi folks,

I've been using this script to accelerate mouse scrolling speed for a while now. Its only flaw is that it doesn't work for horizontal scrolling. I couldn't figure out how to make it work for horizontal scrolling. Would someone please modify the code, so it would support this functionality.

Code: Select all


#Persistent
#NoEnv
#NoTrayIcon
#SingleInstance
#MaxHotkeysPerInterval 120




Process, Priority, , H
SendMode Input

; Show scroll velocity as a tooltip while scrolling. 1 or 0.
tooltips := 0

; The length of a scrolling session.
; Keep scrolling within this time to accumulate boost.
; Default: 500. Recommended between 400 and 1000.
timeout := 50

; If you scroll a long distance in one session, apply additional boost factor.
; The higher the value, the longer it takes to activate, and the slower it accumulates.
; Set to zero to disable completely. Default: 30.
boost := 100

; Spamming applications with hundreds of individual scroll events can slow them down.
; This sets the maximum number of scrolls sent per click, i.e. max velocity. Default: 60.
limit := 10

; Runtime variables. Do not modify.
distance := 0
vmax := 1

; Key bindings
WheelUp::    Goto Scroll
WheelDown::  Goto Scroll
#WheelUp::   Suspend ;disable the script when necessary
; #WheelDown:: Goto Quit 
Scroll:
	t := A_TimeSincePriorHotkey
	if (A_PriorHotkey = A_ThisHotkey && t < timeout)
	{
		; Remember how many times we've scrolled in the current direction
		distance++

		; Calculate acceleration factor using a 1/x curve
		v := (t < 80 && t > 1) ? (250.0 / t) - 1 : 1

		; Apply boost
		if (boost > 1 && distance > boost)
		{
			; Hold onto the highest speed we've achieved during this boost
			if (v > vmax)
				vmax := v
			else
				v := vmax

			v *= distance / boost
		}

		; Validate
		v := (v > 1) ? ((v > limit) ? limit : Floor(v)) : 1

		if (v > 1 && tooltips)
			QuickToolTip("×"v, timeout)

		MouseClick, %A_ThisHotkey%, , , v
	}
	else
	{
		; Combo broken, so reset session variables
		distance := 0
		vmax := 1

		MouseClick %A_ThisHotkey%
	}
	return

Quit:
	QuickToolTip("Exiting Accelerated Scrolling...", 1000)
	Sleep 1000
	ExitApp


Thanks in advance.

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

Re: Accelerated horizontal scrolling

Post by mikeyww » 06 Jul 2022, 20:44

Welcome to this AutoHotkey forum!

Just a starting idea for you: here are the wheel key names. https://www.autohotkey.com/docs/KeyList.htm#mouse-wheel

User avatar
neovis
Posts: 34
Joined: 12 Jun 2022, 03:56
Location: Republic of Korea
Contact:

Re: Accelerated horizontal scrolling  Topic is solved

Post by neovis » 06 Jul 2022, 20:54

Horizontal scrolling is available with WheelLeft and WheelRight.

Add hotkey for horizontal scrolling in this case ^WheelUp and ^WheelDown.

Code: Select all

^WheelUp:: goto Scroll
^WheelDown:: goto Scroll
Change ^WheelUp to WheelLeft, ^WheelDown to WheelRight

Code: Select all

Scroll:
switch (a_thisHotkey) {
    case "^WheelUp":
        button := "WheelLeft"
    case "^WheelDown":
        button := "WheelRight"
    default:
        button := a_thisHotkey
}

t := A_TimeSincePriorHotkey
if (A_PriorHotkey = A_ThisHotkey && t < timeout)
{
    ; Remember how many times we've scrolled in the current direction
    distance++

    ; Calculate acceleration factor using a 1/x curve
    v := (t < 80 && t > 1) ? (250.0 / t) - 1 : 1

    ; Apply boost
    if (boost > 1 && distance > boost)
    {
        ; Hold onto the highest speed we've achieved during this boost
        if (v > vmax)
            vmax := v
        else
            v := vmax

        v *= distance / boost
    }

    ; Validate
    v := (v > 1) ? ((v > limit) ? limit : Floor(v)) : 1

    if (v > 1 && tooltips)
        QuickToolTip("×"v, timeout)

    MouseClick, %button%, , , v
}
else
{
    ; Combo broken, so reset session variables
    distance := 0
    vmax := 1

    MouseClick %button%
}
return

Zek
Posts: 2
Joined: 06 Jul 2022, 14:06

Re: Accelerated horizontal scrolling

Post by Zek » 07 Jul 2022, 08:58

neovis wrote:
06 Jul 2022, 20:54
Horizontal scrolling is available with WheelLeft and WheelRight.

Add hotkey for horizontal scrolling in this case ^WheelUp and ^WheelDown.

Code: Select all

^WheelUp:: goto Scroll
^WheelDown:: goto Scroll
Change ^WheelUp to WheelLeft, ^WheelDown to WheelRight

Code: Select all

Scroll:
switch (a_thisHotkey) {
    case "^WheelUp":
        button := "WheelLeft"
    case "^WheelDown":
        button := "WheelRight"
    default:
        button := a_thisHotkey
}

t := A_TimeSincePriorHotkey
if (A_PriorHotkey = A_ThisHotkey && t < timeout)
{
    ; Remember how many times we've scrolled in the current direction
    distance++

    ; Calculate acceleration factor using a 1/x curve
    v := (t < 80 && t > 1) ? (250.0 / t) - 1 : 1

    ; Apply boost
    if (boost > 1 && distance > boost)
    {
        ; Hold onto the highest speed we've achieved during this boost
        if (v > vmax)
            vmax := v
        else
            v := vmax

        v *= distance / boost
    }

    ; Validate
    v := (v > 1) ? ((v > limit) ? limit : Floor(v)) : 1

    if (v > 1 && tooltips)
        QuickToolTip("×"v, timeout)

    MouseClick, %button%, , , v
}
else
{
    ; Combo broken, so reset session variables
    distance := 0
    vmax := 1

    MouseClick %button%
}
return
Thank you so freaking much, it worked!

Post Reply

Return to “Ask for Help (v1)”