i just packed few dllcalls and sendmessages for Scrollbars
note that it works on standard scrollbar only. which means not compatible with IE/Firefox
Download SB.ahk to /Lib
Code:
; - Parameters
; hwnd = Unique ID(hwnd) of the control where Scrollbar belongs to, not window
; Which = "V"(vertical) or "H"(horizontal), can be 1(V) or 0(H) too
; - Basic Functions
; SB_GetPos(hwnd, Which="V")
; SB_SetPos(hwnd, Which="V", To="0") ;it does not scroll the pages actually
; SB_GetRange(hwnd, Which="V") ;eg) Min,Max
; SB_Show(hwnd, Which="V") ;Use carefully
; SB_Hide(hwnd, Which="V") ;Use carefully
;
; - Functions To scroll the page actually
; SB_LineUP(hwnd, Which="V")
; SB_LineDown(hwnd, Which="V")
; SB_PageUp(hwnd, Which="V")
; SB_PageDown(hwnd, Which="V")
; SB_Top(hwnd, Which="V")
; SB_Bottom(hwnd, Which="V")
ExampleCode:
SetKeyDelay, -1
Run, Notepad
WinWait, ahk_class Notepad
WinMove, ,, 0, 0, 400, 400
WinWaitActive
Loop, 100
SendInput, LineNumber : %A_Index% {Enter}
Loop, 200
SendInput, {Space}
SendInput, LineEnd
;Get hwnd of control where the scrollbar belongs to
ControlGet, Notepad, hwnd,, Edit1, ahk_class Notepad
;Start to controlling the scrollbars
MsgBox, % "Range of Vertical scrollbar is (Min,Max) : " SB_GetRange(Notepad)
MsgBox, % "Range of Horizontal scrollbar is (Min,Max) : " SB_GetRange(Notepad,"H")
MsgBox, Move scrollbars without scrolling (SB_SetPos)
SB_SetPos(Notepad,"V",0), SB_SetPos(Notepad,"H",0)
MsgBox, Hide scrollbars (SB_Hide)
SB_Hide(Notepad), SB_Hide(Notepad,"H")
MsgBox, Show scrollbars again (SB_Show)
SB_Show(Notepad), SB_Show(Notepad,"H")
MsgBox, Scroll One Line UP (SB_LineUp)
SB_LineUP(Notepad)
MsgBox, Scroll Two Lines DOWN (SB_LineDown)
SB_LineDown(Notepad),SB_LineDown(Notepad)
MsgBox, Repeat on Horizontal scrollbar too (SB_LineDown)
SB_LineDown(Notepad,"H"),SB_LineDown(Notepad,0) ;for 2nd param, H and 0 are same
MsgBox, Scroll page left (SB_PageUp)
SB_PageUp(Notepad,"H")
MsgBox, Scroll to the leftmost (SB_Top)
SB_Top(Notepad,0)
MsgBox, Scroll page UP (SB_PageUp)
SB_Pageup(Notepad)
MsgBox, Scroll page DOWN (SB_PageDown)
SB_PageDown(Notepad)
MsgBox, Scroll page to the top (SB_Top)
SB_Top(Notepad)
MsgBox, Scroll page to the bottom (SB_Bottom)
SB_Bottom(Notepad)
MsgBox, Done !
WinClose
Sleep, 200
Send, {N}
Exitapp
_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at
PlayAHK.com