Parallel Scrolling script to scroll 2 windows simultaneously
Posted: 29 Feb 2024, 00:05
This Autohotkey script allows you to scroll 2 windows or any views in the same window simultaneously. When you hold down the win key, the script sends a scroll event to both the current point under the course, and a second point mirrored horizontally. Thus, by choosing the cursor position, you can achieve simultaneous scrolling of any 2 windows or 2 lists within a single window.
You can adjust scrolling speed by modifying the "WheelTurns" variable.
If you hold Win+Alt, you can set any custom point for scroll by clicking on the screen, and then scrolling with both Win and Alt key pressed will also scroll at stored position
The only problem I found for now is that Alt and Win keys are also sent to the target windows along with scroll events. Some windows may respond differently to scroll with Win or Alt keys — such as VSCode, which has ability to scroll faster when Alt key is pressed.
Demonstration of parallel scrolling two windows simultaneously when Win key is pressed (cursor is over left window):
You can adjust scrolling speed by modifying the "WheelTurns" variable.
If you hold Win+Alt, you can set any custom point for scroll by clicking on the screen, and then scrolling with both Win and Alt key pressed will also scroll at stored position
Code: Select all
; Parallel scrolling
; Autohotkey script by @emvaized
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#KeyHistory 0
ListLines Off
SetMouseDelay, -1
; Preference for scrolling speed. Defines how much scroll events to send on every detected scroll.
WheelTurns := 5
#WheelUp:: ScrollPoint("WheelUp", WheelTurns)
Return
#WheelDown:: ScrollPoint("WheelDown", WheelTurns)
Return
!#WheelUp:: ScrollPoint("WheelUp", WheelTurns, SavedX, SavedY )
Return
!#WheelDown:: ScrollPoint( "WheelDown", WheelTurns, SavedX, SavedY )
Return
; Save cursor position on Win+Alt+click
#!LButton::
{
CoordMode, Mouse, Screen
MouseGetPos, SavedX, SavedY
ToolTip, Saved point for scroll: %SavedX% x %SavedY%`
Sleep 1000
ToolTip
}
ScrollPoint(WhichButton, WheelTurns, PasX = -1, PasY = -1) {
; Get desktop size and mouse position
CoordMode, Mouse, Screen
WinGetPos, , , Xmax, , Program Manager
MouseGetPos, MouseX, MouseY
Loop, %WheelTurns% {
; Scroll at current position
MouseClick, %WhichButton% , , , 1, 0, ,
if (PasX > -1) {
; Move to previously saved cursor position
MouseClick, %WhichButton% , PasX, PasY, 1, 0, ,
} else {
; Move to horizontally mirrored position and scroll
MouseClick, %WhichButton% , (Xmax - MouseX), MouseY, 1, 0, ,
}
; Move cursor back
MouseMove, MouseX, MouseY ,0 ,
}
}
Demonstration of parallel scrolling two windows simultaneously when Win key is pressed (cursor is over left window):