Skip to content

Instantly share code, notes, and snippets.

@sd016808
Last active August 17, 2022 15:12
Show Gist options
  • Save sd016808/6886d545d8416a49a9a912bd14050dc2 to your computer and use it in GitHub Desktop.
Save sd016808/6886d545d8416a49a9a912bd14050dc2 to your computer and use it in GitHub Desktop.
TabsOnWheels: Switch browser (or other program's) tabs with your mouse wheel when hovering over the tab bar (and optionally address bar). Press Middle/Wheel Mouse Click to switch tabs from anywhere in the program.
; ---------------------------------------------------- ;
; TabsOnWheels ;
; ---------------------------------------------------- ;
; Switch browser (or other program's) tabs with your mouse wheel when hovering over the tab bar (and optionally address bar).
; Press Middle/Wheel Mouse Click to switch tabs from anywhere in the program.
; If the target window is inactive when starting to scroll, it will be activated.
;
; Install https://www.autohotkey.com/ (Windows only) to run.
; To auto-start, copy the script or a shortcut to your
; Start Menu\Programs\Startup directory
; (%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup)
;
; Modify from https://gist.github.com/Chematronix/5d7e12f7e580652aac46dc8080906e4f Chematronix
; Fix the issues when using the script prevents middle mouse button click and drag scrolling
; and some people need to use administrator privileges to run the script.
; Area to enable tab wheel scroll. ~45 for tab bar, ~80 to include address bar
tabAreaHeight := 80
; Key or button to enable tab scrolling anywhere in the program. RButton for right mouse button, MButton for Middle/Wheel button.
tabSwitchAnywhereKey := "MButton"
; List of WindowClass: "Descriptions". Change a program's "Description" to False to disable it.
enabledPrograms := {Chrome_WidgetWin_1: "Chrome, Chromium", MozillaWindowClass: "Firefox", IEFrame: "Internet Explorer", ApplicationFrameWindow: "Edge", "Notepad++": "Notepad++", TMainForm: "HeidiSQL - heidisql.exe", "SunAwtFrame_NotWorking": "IntelliJ Idea - idea64.exe", AcrobatSDIWindow: "Adobe Acrobat DC Pro", Solitaire: False}
VERSION := 3
#NoEnv ; Disable using enviroment variables without calling EnvGet(), for performance.
#Warn ; Detect common errors.
#SingleInstance force
#UseHook Off ; Using the keyboard hook is usually preferred for hotkeys - but here we only need the mouse hook.
#InstallMouseHook
#MaxHotkeysPerInterval 1000 ; Avoids warning messages for high speed wheel users.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
Menu, Tray, Tip, TabsOnWheels %VERSION%
Menu, Tray, Icon, imageres.dll, 306
WheelUp::
WheelDown::
CoordMode, Mouse, Screen
MouseGetPos, mouseXPos, mouseYPos, winId
WinGetPos, winXPos, winYPos, winWidth, winHeight, ahk_id %winId%
WinGetClass, winClass, ahk_id %winId% ; Get Window class
If (enabledPrograms.hasKey(winClass) AND !GetKeyState(tabSwitchAnywhereKey, "P") AND (mouseYPos > winYPos and mouseYPos < winYPos + tabAreaHeight))
{
IfWinNotActive ahk_id %winId%
WinActivate ahk_id %winId%
If A_ThisHotkey = WheelUp
Send ^{PgUp}
Else
Send ^{PgDn}
}
Else
{
If A_ThisHotkey = WheelUp
Send {WheelUp}
Else
Send {WheelDown}
}
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment