具体要平滑滚动来干什么
捕捉滚动条的位置
这里面有没有什么可参考的地方
#NoEnv #SingleInstance Force SetBatchLines -1 SetTimer, DebugView, 75 initSpeed := speed := 50 initDelay := delay := 1 ; caution with delay = 0 Loop { xDir := yDir := 0 (up := GetKeyState("r", "P")) ? --yDir (down := GetKeyState("f", "P")) ? ++yDir (left := GetKeyState("e", "P")) ? ++xDir (right := GetKeyState("q", "P")) ? --xDir if (xDir && yDir) { x := Round(xDir * speed * 0.707) y := Round(yDir * speed * 0.707) } else { x := xDir * speed y := yDir * speed } mouseMove(x, y, delay) } Return ^Esc::ExitApp *Numpad5::speed := initSpeed, delay := initDelay ; reset all ; inc/dec pixel movement step size *Numpad7::++speed *Numpad1::(--speed < initSpeed) ? speed := initSpeed ; inc/dec sleep delay *Numpad9::++delay *Numpad3::(--delay < initDelay) ? delay := initDelay ; suppress native function *f:: *e:: *q:: *r:: Return DebugView: { ToolTip, % Format(dbg , speed , delay , (invertAxis ? "Inverted" : "Normal") , x , xDir , y , yDir , up , left , down , right), 100, 200, 20 Return } mouseMove(x, y, delay) { DllCall("mouse_event", "UInt", 0x0001, "UInt", x, "UInt", y, "UInt", 0, "UInt64P", 0) DllCall("Sleep", "UInt", delay) } 1::MouseMove, -10000, 0, 0, R 2::MouseMove, 10000, 0, 0, R
#define SW_SMOOTHSCROLL 0x0010
DllCall("User32.dll\ScrollWindowEx", "ptr", hwnd, "int", x, "int", y, "ptr", 0, "ptr", &rect, "ptr", 0, "ptr", 0, "Uint", 16)
; 高精度滚轮,以像素为单位滚动鼠标所在窗口 ; http://msdn.microsoft.com/en-us/library/windows/desktop/ms645617(v=vs.85).aspx PostMW(deltay, deltax := 0) { MouseGetPos,x,y, id, control ; 获取鼠标所在窗口id Modifiers := 0x8*GetKeyState("ctrl") | 0x1*GetKeyState("lbutton") | 0x10*GetKeyState("mbutton") |0x2*GetKeyState("rbutton") | 0x4*GetKeyState("shift") | 0x20*GetKeyState("xbutton1") |0x40*GetKeyState("xbutton2") if (deltay != 0) PostMessage, 0x20A, deltay << 16 | Modifiers, y << 16 | x ,, ahk_id %id% if (deltax != 0) PostMessage, 0x20E, deltax << 16 | Modifiers, y << 16 | x ,, ahk_id %id% } f3:: ;向上 PostMW(1) return f4:: ;向下 PostMW(-1) return f5:: ;向左 PostMW(0,-1) return f6:: ;向右 PostMW(0,1) return
-:: dx := 0 dy := 50 ControlGet, OutputVar, Hwnd,, Edit1, ahk_exe NOTEPAD.EXE Result := DllCall("User32.dll\ScrollWindowEx", "Ptr", OutputVar, "Int", dx, "Int", dy, "Ptr", 0, "Ptr", 0, "Ptr", 0, "Ptr", 0, "Uint", 0) return
(同类脚本最慢都是每次滚3行,直接映射滚轮键受限于win系统的设置)
These options are affected by the mouse wheel speed adjusted on Control Panel. If you don't have a mouse with wheel, the default is 3 +/- lines per option button press
意思是修改win设置 就可以改变脚本调用WheelDown的滚动行数。
但这样使用普通鼠标时又不爽了所以我想还是不要从“映射滚轮”这个方向入手,找找有没有不用滚轮的滚动方式,比如映射笔记本触摸板
但再次感受了下 适用范围是有点小窄 ...
#4看一眼大概就是直接解决方案了 ... 不知道LZ试出来没 ~
#5 好吧 ......
用记事本测试了滚动功能。滚动起来有残影,滚动不依赖滚动条。
这个API不好用