Forum Discussion

MulgraveTester's avatar
MulgraveTester
Frequent Contributor
9 years ago
Solved

How can I use scroll bar methods

I have a script that uses [PageDown] to move from the top of a SysListView32 to the bottom. Unfortunately the [PageDown] key causes unwanted behaviour so I want to use the vertical scroll bar instead...
  • djadhav's avatar
    djadhav
    9 years ago

    What I usually do is this

     

    'Prepare to know when to stop scrolling
    'Identify an object on the top of the page/list to know that you've scrolled completely to the top
    	SET objTop = objParent.FindChild(PropArray, ValuesArray, depth)
    'Identify an object on the botton of the page/list to know that you've scrolled completely to the top
    	SET objBottom = objParent.FindChild(PropArray, ValuesArray, depth)
    
    'Scroll to the required object	
    'Find the object that we are interested in 	
    	SET objChild = objParent.FindChild(PropArray, ValuesArray, depth)
    	IF objChild.VisibleOnScreen THEN
    		'Do something with the object
    	ELSE
    		DO WHILE NOT objTop.VisibleOnScreen
    			lib_MouseScrollUp(objPage,5) 'Find a number that sufficiently scrolls for you and use scroll up or down methods as required
    			IF objChild.VisibleOnScreen THEN EXIT DO 
    		LOOP
    END IF
    
    'Functions for scrolling
    
    FUNCTION lib_MouseScrollUp(ByRef obj, ByVal count)
      obj.MouseWheel count
    END FUNCTION
    
    'OR
    
    FUNCTION lib_MouseScrollDown(ByRef obj, ByVal count)  
      obj.MouseWheel 0-count
    END FUNCTION