调整 Windows 10 滚动条以默认跳转到点击位置

调整 Windows 10 滚动条以默认跳转到点击位置

在 Windows 10 中(可能所有其他 Windows 版本也是如此),单击滚动条手柄上方或下方的滚动条会向上或向下滚动一页。但我想跳转到单击的位置。已经有这个功能了Shift,可通过使用+或(在某些应用程序中)右键单击并从上下文菜单中选择“滚动到此处”来触发Click。但我希望该功能成为默认行为。

如何使“滚动到此处”成为滚动条左键单击的默认操作?

理想情况下,应该有一个注册表设置或类似的东西。但我也愿意接受一些黑客攻击,比如 AutoHotKey 脚本,它可以检测滚动条上的左键单击,并Shift为这些单击注入一个。

答案1

尝试这个 AutoHotkey 脚本:

~LButton Up::
    ; Get the current position of the mouse cursor:
    MouseGetPos, MouseX, MouseY, A ; A means the active window
    ; Get the position and size of the active window:   
    WinGetPos, WinX, WinY, WinWidth, WinHeight, A
    If (MouseX > (WinWidth - 20) and MouseX < WinWidth and MouseY > 200) ; right edge 
        SendInput, +{Click} ; + is the symbol for Shift
return

https://www.autohotkey.com/docs/commands/MouseGetPos.htm https://www.autohotkey.com/docs/commands/WinGetPos.htm https://www.autohotkey.com/docs/Hotkeys.htm#Symbols

答案2

这是改编自这个答案修复了一些错误并添加了一个过滤器,使得脚本仅在预定义的应用程序中激活。

仍有改进空间。例如,您无法再拖动滚动手柄。

自动热键脚本

#NoEnv
#Warn All

#If MouseIsOverScrollbar("firefox|chrome|notepad|hh")
LButton::
    ; "+" is the modifier for shift
    SendInput, +{Click}
return
#If

MouseIsOverScrollbar(Exe_Regex) {
    if (A_Cursor != "Arrow")
        return False

    MouseGetPos, _X, _Y, WindowUnderMouse

    WinGet, Exe, ProcessName, ahk_id %WindowUnderMouse%
    if (not Exe ~= "^(" . Exe_Regex . ")\.exe")
        return False

    WinActivate, ahk_id %WindowUnderMouse%
    MouseGetPos, MouseX, MouseY
    WinGetPos, _X, _Y, WinWidth, _H, ahk_id %WindowUnderMouse%
    ScrollbarWidth = 25
    HeaderWidth = 40
    return MouseX > WinWidth - ScrollbarWidth
       and MouseY > HeaderWidth
}

对于 AutoHotKey 2 您可能需要切换到CoordMode, Mouse, ClientWinGetClientPos

对于调试,我发现SoundPlay *-1只要插入 Shift+Click 就会很有帮助。

相关内容