From e34d511ff4ab6516432abd4f67866c1c3ff67d79 Mon Sep 17 00:00:00 2001 From: Maxim Biro <nurupo.contributions@gmail.com> Date: Tue, 29 Aug 2017 09:48:53 -0400 Subject: [PATCH] Add option to reverse scroll direction FireFox does mouse wheel tab scrolling in the opposite direction, so if you use both Chrome and FireFox, you will have hard time remembering which way to scroll. Using this option you can make Chrome's tabs scroll in the same direction as FireFox tabs do. --- chrome-mouse-wheel-tab-scroller.au3 | 52 +++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/chrome-mouse-wheel-tab-scroller.au3 b/chrome-mouse-wheel-tab-scroller.au3 index 371904a..64cd2aa 100644 --- a/chrome-mouse-wheel-tab-scroller.au3 +++ b/chrome-mouse-wheel-tab-scroller.au3 @@ -29,7 +29,7 @@ #AutoIt3Wrapper_Res_Icon_Add=icon_disabled.ico #AutoIt3Wrapper_Res_Comment=Scroll Chrome tabs using mouse wheel #AutoIt3Wrapper_Res_Description=Scroll Chrome tabs using mouse wheel -#AutoIt3Wrapper_Res_Fileversion=0.1.0.0 +#AutoIt3Wrapper_Res_Fileversion=0.2.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Maxim Biro #include "MouseOnEvent.au3" @@ -39,24 +39,48 @@ Const $CHROME_TABS_AREA_HEIGHT_NOT_MAXIMIZED = 48 Const $CHROME_NONTABS_AREA_RIGHT_WIDTH_OFFSET_MAXIMIZED = 200 Const $CHROME_NONTABS_AREA_RIGHT_WIDTH_OFFSET_NOT_MAXIMIZED = 150 -Dim Const $HOOKS[2][2] = [ _ - [$MOUSE_WHEELSCROLLUP_EVENT, "mouseWheelUp"], _ - [$MOUSE_WHEELSCROLLDOWN_EVENT, "mouseWheelDown"] _ - ] +Const $CFG_DIR_PATH = @AppDataDir & "\chrome-mouse-wheel-tab-scroller" +Const $CFG_FILE_PATH = $CFG_DIR_PATH & "\config.ini" +$CFG_REVERSE = False -registerHooks() +Dim $HOOKS[2][2] = [ _ + [$MOUSE_WHEELSCROLLUP_EVENT, "mouseWheelUp"], _ + [$MOUSE_WHEELSCROLLDOWN_EVENT, "mouseWheelDown"] _ + ] Opt("TrayMenuMode", 1) +$trayReverse = TrayCreateItem("Reverse scroll direction") $trayDisable = TrayCreateItem("Disable (Gaming Mode)") $trayExit = TrayCreateItem("Exit") TraySetClick(16) TraySetState() +readConfig() + +If $CFG_REVERSE Then + TrayItemSetState($trayReverse, $TRAY_CHECKED) + swapHooks() +EndIf + +registerHooks() + While 1 $msg = TrayGetMsg() Select Case $msg = $trayExit Exit + Case $msg = $trayReverse + $CFG_REVERSE = Not $CFG_REVERSE + writeConfig() + + $trayDisableState = TrayItemGetState($trayDisable) + If BitAnd($trayDisableState, $TRAY_UNCHECKED) Then + unregisterHooks() + EndIf + swapHooks() + If BitAnd($trayDisableState, $TRAY_UNCHECKED) Then + registerHooks() + EndIf Case $msg = $trayDisable $trayDisableState = TrayItemGetState($trayDisable) Select @@ -84,6 +108,12 @@ Func unregisterHooks() Next EndFunc +Func swapHooks() + $tmp = $HOOKS[0][0] + $HOOKS[0][0] = $HOOKS[1][0] + $HOOKS[1][0] = $tmp +EndFunc + Func isMouseInChromeTabsArea() $windowList = WinList("[REGEXPCLASS:Chrome_WidgetWin_]") For $i = 1 To $windowList[0][0] @@ -120,3 +150,13 @@ Func mouseWheelDown() Send("^{PGDN}") EndIf EndFunc + +Func readConfig() + $CFG_REVERSE = IniRead($CFG_FILE_PATH, "options", "reverse", "False") == "True" +EndFunc + +Func writeConfig() + DirCreate($CFG_DIR_PATH) + + IniWrite($CFG_FILE_PATH, "options", "reverse", String($CFG_REVERSE)) +EndFunc