
I just had to post this script!
I initially used a couple of months making this work in C using Win32 API some years ago, but using AutoHotkey it just took a couple of hours!
It scrolls a window using the right and left mouse buttons. It works like a charm, but it would be smoother if cmallet would make the Send,{WheelUp} work.
It uses a mousehook and triggers on right mouse button down, checks where on the screen the click was, waits 200ms, checks which buttons are down and acts accordingly, loops until the right mouse is released, cheks which buttons are down and acts accordingly.
Skrommel
Code:
;STARTOFSCRIPT
; Scroll a window using the mouse
;
; Usage:
;
; Right click = Right click
; Right hold and drag up = PageUp
; Right hold and drag down = PageDown
; Slow right click above middle of window = PageUp
; Slow right click below middle of window = PageDown
; Left hold and right click above middle of window = Top of page
; Left hold and right click below middle of window = Bottom of page
; Left hold and right hold above middle of window = Previous page
; Left hold and right hold below middle of window = Next page
SetWinDelay,0
$RButton::
SetEnv,moved,0
WinGetActiveStats,title,width,height,wx,wy
MouseGetPos,mx1,my1
EnvDiv,height,2
IfLess,my1,%height%
SetEnv,scroll,U
Else
SetEnv,scroll,D
Sleep,200
GetKeyState,lb,LButton,P
GetKeyState,rb,RButton,P
SetEnv,state,%lb%%rb%%scroll%
IfEqual,state,UDU
{
SetEnv,splash,Up
Gosub,SHOW
}
IfEqual,state,UDD
{
SetEnv,splash,Down
Gosub,SHOW
}
IfEqual,state,UUU
{
MouseClick,RIGHT
SetEnv,splash,RClick
Gosub,SHOW
Goto,END
}
IfEqual,state,UUD
{
MouseClick,RIGHT
SetEnv,splash,RClick
Gosub,SHOW
Goto,END
}
IfEqual,state,DUU
{
MouseClick,left,,,,,U
Send,^{Home}
SetEnv,splash,Top
Gosub,SHOW
Goto,END
}
IfEqual,state,DUD
{
MouseClick,left,,,,,U
Send,^{End}
SetEnv,splash,Bottom
Gosub,SHOW
Goto,END
}
MOVING:
Sleep,0
GetKeyState,lb,LButton,P
GetKeyState,rb,RButton,P
SetEnv,state,%lb%%rb%%scroll%
IfEqual,state,UUU
{
IfEqual,moved,0
{
Send,{PgUp}
SetEnv,splash,Up
Gosub,SHOW
Goto,END
}
Goto,END
}
IfEqual,state,UUD
{
IfEqual,moved,0
{
Send,{PgDn}
SetEnv,splash,Down
Gosub,SHOW
Goto,END
}
Goto,END
}
IfEqual,state,DDU
{
MouseClick,left,,,,,U
Send,{BROWSER_BACK}
SetEnv,splash,Back
Gosub,SHOW
Goto,END
}
IfEqual,state,DDD
{
MouseClick,left,,,,,U
Send,{BROWSER_FORWARD}
SetEnv,splash,Forward
Gosub,SHOW
Goto,END
}
MouseGetPos,mx2,my2
SetEnv,amounty,%my1%
EnvSub,amounty,%my2%
IfLess,amounty,-15
{
SetEnv,my1,%my2%
SetEnv,moved,1
Send,{PgDn}
SetEnv,splash,Down
Gosub,SHOW
}
IfGreater,amounty,15
{
SetEnv,my1,%my2%
SetEnv,moved,1
Send,{PgUp}
SetEnv,splash,Up
Gosub,SHOW
}
Goto,MOVING
SHOW:
WinGetActiveStats,title,width,height,wx,wy
MouseGetPos,mx3,my3
EnvAdd,mx3,%wx%
EnvAdd,my3,%wy%
EnvSub,mx3,60
SplashTextOn,50,0,%splash%
WinWait,%splash%
WinMove,%mx3%,%my3%
Return
END:
Sleep,400
SplashTextOff
Return
;ENDOFSCRIPT