This class provides scrollable Gui functionality for AutoHotkey v1 and v2, with dynamic scroll range updates.
It supports horizontal and vertical scrolling, mouse wheel scrolling, and resize-aware behavior.
It also provides optional focus-aware wheel routing for common controls (Edit/UpDown, ComboBox, etc.).
For version-specific integration code, see the main-ahkv1 and main-ahkv2 branches of this repository.
For runnable examples, see the examples/ folder.
- Vertical + horizontal scrollbars
- Mouse wheel scrolling
Shift + Wheel→ horizontal scroll (common Windows UX)- Optional focus-aware wheel routing for common controls
- Resize-aware updates
- Recalculates scroll ranges/pages during sizing
- Scrolls window contents to match the new scroll positions
- Helpers
- Calculate the bounding rectangle of child controls
- Update the stored content boundary and optionally apply GUI MaxSize
- AutoHotkey v2.0.0+ (for the v2 branch)
- AutoHotkey v1.1.35+ (for the v1 branch)
- Copy
ScrollableGui.ahkinto your project (or add this repository as a submodule). #Includeit.- Call
ScrollableGui.init()once (global message hooks). - Register a GUI window with
ScrollableGui.register().
Registers internal message handlers (WM_VSCROLL, WM_HSCROLL, WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_SIZING, etc.).
Call once per script.
Registers a window as scrollable.
innerScrollOnFocus(defaulttrue): when focus is inside a child control, wheel input may be routed to that control when appropriate.
Stops managing the window.
If ScrollableGui.init() is active (it hooks WM_DESTROY), the window is automatically unregistered when it is destroyed—so an explicit call is usually unnecessary.
Returns whether the window is registered.
Toggles focus-based wheel routing after registration.
Forces recalculation of scroll ranges/pages using current window size and stored boundary.
ScrollableGui.calculateInnerControlsSize(hWndOrGui, &left?, &top?, &right?, &bottom?, visibleControlsOnly := true) -> true/false
Computes the bounding rectangle of child controls.
Returns the stored content boundary size.
Updates stored boundary (content size), then calls syncSize().
Optionally applies MaxSize to clamp resizing.
This project started as a response to a forum question/request:
Project threads:
- v2: https://www.autohotkey.com/boards/viewtopic.php?t=139976
- v1: https://www.autohotkey.com/boards/viewtopic.php?t=139977
Special thanks to Lexikos. Without the original forum post
Scrollable GUI - Proof of Concept,
this project would not have been possible to begin in the first place.
MIT License
