AutoHotkey Community

It is currently May 26th, 2012, 4:43 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: June 14th, 2008, 6:39 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 31st, 2008, 8:00 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2008, 8:56 am 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 1st, 2008, 11:59 am 
Yes, indeed, I was missing something obvious. Works! Very Cool! Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2009, 1:19 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Rajat, Yahoo [Bot] and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group