婆罗门
精华
|
战斗力 鹅
|
回帖 0
注册时间 2014-6-11
|
本帖最后由 JMNSY 于 2026-8-29 19:55 编辑
无级滚轮我已经用ahk替代了,随便来个什么鼠标都能有7成以上体验
- #Requires AutoHotkey v2.0
- #SingleInstance Force
- SendMode "Event" ; 设置为兼容性更好的Event模式
- SetKeyDelay 30, 30 ; 增加按键延迟,使其更贴近真实按键
- Persistent
- ; 不需要在高权限窗口中使用的可以去掉该分支,就可以用普通权限启动
- if not A_IsAdmin
- {
- try
- Run "*RunAs " A_ScriptFullPath
- ExitApp
- }
- ~WheelDown::HandleWheel(1)
- ~WheelUp::HandleWheel(-1)
- ; ============================================================
- ; 滚轮动态巡航加速 (v2)
- ; 功能:快速连续滚动 → 自动进入巡航;按修饰键 / 离开窗口 → 停止
- ; ============================================================
- ; ========== 可调参数 ==========
- timeWindow := 100 ; 手动滚动累积时间窗口(ms),每次滚动与上一次滚动均小于该时间时,累计次数,否则清空
- thresholdTicks := 8 ; 触发巡航所需手动滚动次数
- baseSpeed := 30 ; 巡航初始速度(每秒滚轮行数)
- speedIncrement := 15 ; 每次同向加速增量
- maxSpeed := 150 ; 速度上限
- timerInterval := 30 ; 滚动发送间隔(ms)
- windowCheckInterval := 30 ; 窗口检查间隔(ms),越大越省 CPU,但移出窗口停止反应稍慢
- ; ================================
- ; 内部状态
- direction := 0 ; 1=向下,-1=向上,0=无
- autoMode := false
- tickCount := 0
- lastTick := 0
- currentSpeed := 0.0
- accumulated := 0.0
- cruiseHwnd := 0 ; 巡航启动时所在窗口
- lastHwnd := 0 ; 上一次手动滚动时的窗口
- lastWindowCheck := 0 ; 上次窗口检查时间戳
- ; ========== 函数 ==========
- ; 定时器:发送滚动消息,并进行窗口检查
- AutoScroll_Timer()
- {
- global direction, currentSpeed, timerInterval, accumulated, autoMode, cruiseHwnd
- global lastWindowCheck, windowCheckInterval
- ; 1. 修饰键保护
- if GetKeyState("Ctrl", "P") || GetKeyState("Alt", "P") || GetKeyState("Shift", "P") || GetKeyState("LWin", "P") || GetKeyState("RWin", "P")
- {
- StopAutoScroll()
- return
- }
- ; 2. 防溅射:按设定间隔检查鼠标是否还在巡航窗口
- if (A_TickCount - lastWindowCheck >= windowCheckInterval)
- {
- MouseGetPos(, , &hwnd)
- lastWindowCheck := A_TickCount
- if (hwnd != cruiseHwnd)
- {
- StopAutoScroll()
- return
- }
- }
- if (!autoMode || direction == 0)
- return
- ; 3. 累计滚动量,发送消息
- accumulated += currentSpeed * (timerInterval / 1000)
- if (accumulated >= 1)
- {
- count := Floor(accumulated)
- accumulated -= count
- if (direction == 1)
- SendInput("{Blind}{WheelDown " count "}")
- else
- SendInput("{Blind}{WheelUp " count "}")
- }
- }
- ; 启动巡航
- StartAutoScroll(dir)
- {
- global autoMode, direction, currentSpeed, baseSpeed, cruiseHwnd, accumulated, lastWindowCheck
- autoMode := true
- direction := dir
- currentSpeed := baseSpeed
- accumulated := 0.0
- MouseGetPos(, , &cruiseHwnd)
- lastWindowCheck := A_TickCount
- SetTimer(AutoScroll_Timer, timerInterval)
- }
- ; 停止巡航
- StopAutoScroll()
- {
- global autoMode, direction, tickCount, currentSpeed, accumulated
- SetTimer(AutoScroll_Timer, 0)
- autoMode := false
- direction := 0
- tickCount := 0
- currentSpeed := 0
- accumulated := 0
- }
- ; 处理手动滚轮事件
- HandleWheel(dir)
- {
- global timeWindow, thresholdTicks, autoMode, direction, tickCount, lastTick, currentSpeed, speedIncrement, maxSpeed
- global lastHwnd, cruiseHwnd
- ; 修饰键保护:任何修饰键按下时,忽略所有额外处理,只保留原生滚动
- if GetKeyState("Ctrl", "P") || GetKeyState("Alt", "P") || GetKeyState("Shift", "P") || GetKeyState("LWin", "P") || GetKeyState("RWin", "P")
- return
- MouseGetPos(, , &hwnd)
- ; ---- 窗口变化处理 ----
- if (hwnd != lastHwnd)
- {
- if (autoMode)
- StopAutoScroll()
- direction := dir
- tickCount := 1
- lastTick := A_TickCount
- lastHwnd := hwnd
- SendInput("{Blind}{Wheel" dir "}")
- return
- }
- ; 巡航中,手动滚动时发现窗口已不是原窗口(额外保险)
- if (autoMode && hwnd != cruiseHwnd)
- {
- StopAutoScroll()
- direction := dir
- tickCount := 1
- lastTick := A_TickCount
- lastHwnd := hwnd
- cruiseHwnd := hwnd
- SendInput("{Blind}{Wheel" dir "}")
- return
- }
- now := A_TickCount
- ; 巡航中同向 → 加速
- if (autoMode && direction == dir)
- {
- currentSpeed := Min(currentSpeed + speedIncrement, maxSpeed)
- return
- }
- ; 巡航中反向 → 停止
- if (autoMode && direction != dir)
- {
- StopAutoScroll()
- }
- ; 手动滚动累积
- if (!autoMode)
- {
- if (direction == dir && (now - lastTick) < timeWindow)
- tickCount += 1
- else
- {
- direction := dir
- tickCount := 1
- }
- lastTick := now
- SendInput("{Blind}{Wheel" dir "}")
- if (tickCount >= thresholdTicks)
- StartAutoScroll(dir)
- return
- }
- }
复制代码 |
评分
-
查看全部评分
|