 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Sat Jun 14, 2008 5:39 pm Post subject: SB() - Functions for Scrollbar |
|
|
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") |
Example
| Code: | 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 |
|
| Back to top |
|
 |
Wishful Guest
|
Posted: Sun Aug 31, 2008 7:00 am Post subject: Error: Call to nonexistent function. |
|
|
I was so excited to see your scripts for controlling scroll bars, but when I pasted your sript in an ahk file and ran it, I get "Error: Call to nonexistent function" for all the SB_ functions.
Am I missing something obvious? |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Sun Aug 31, 2008 7:56 am Post subject: |
|
|
put SB.ahk in the AutoHotkey/Lib directory or #include where the file is located. _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Sep 01, 2008 10:59 am Post subject: Call to nonexistent function |
|
|
| Yes, indeed, I was missing something obvious. Works! Very Cool! Thanks! |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 642
|
Posted: Wed Apr 01, 2009 12:19 pm Post subject: |
|
|
| Code: | | ; SB_SetPos(hwnd, Which="V", To="0") ;it does not scroll the pages actually |
What can we make to make it also scroll? We need a new function which detects the current location of the scrollbar, left mouse clicks on it and keeps pressing, then SB_SetPos and releasing the left mouse button again. This should or could work? Did anyone try this? Using only DllCalls would be also great. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|