Skip to content

Instantly share code, notes, and snippets.

@emvaized
Last active November 1, 2024 16:41
Show Gist options
  • Save emvaized/82201245d9581fb16727bc3977088c64 to your computer and use it in GitHub Desktop.
Save emvaized/82201245d9581fb16727bc3977088c64 to your computer and use it in GitHub Desktop.
Parallel Scrolling script for Autohotkey
; Parallel scrolling
; Autohotkey script by @emvaized
; Licence: MIT
;
; Description: 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 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
#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 ,
}
}
@emvaized
Copy link
Author

emvaized commented Feb 28, 2024

This small 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 changing number of iterations on Loop, 5 line

Demonstration of parallel scrolling two windows simultaneously when Win key is pressed (cursor is over left window):

2024-02-28075245-ezgif com-video-to-gif-converter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment