Jump to content

How to move scroll bar to bottom


pecet
 Share

Go to solution Solved by pecet,

Recommended Posts

I need to get some data from window (third party app). I have handle to this window and I can get data using WInGetText function. The problem is, that interesting part of data is not visible on the screen. So I need to scroll the window down. I have a handle to scroll bar. Now, how can I scroll it down?

I tried to use _SendMessage function, with messages found here: https://msdn.microsoft.com/en-us/library/windows/desktop/ff486023(v=vs.85).aspx

but it looks like these constants are not declared (I get error: undeclared global variable when I try for example something like this:)

#include <StructureConstants.au3>

_SendMessage($hwndCtrl,$SBM_GETSCROLLINFO)

Here: https://www.autoitscript.com/autoit3/docs/libfunctions/_SendMessage.htm

I can see something like that:

Local Const $WM_SYSCOMMAND = 274
Local Const $SC_MONITORPOWER = 61808
_SendMessage($hWnd, $WM_SYSCOMMAND, $SC_MONITORPOWER, $iOnOff)

274 and 61809 - where these values are taken from?

Link to comment
Share on other sites

$hwndCtrl=ControlGetHandle("Edit Composite","","[CLASS:ListBox; INSTANCE:1]")
_GUICtrlListBox_ClickItem($hwndCtrl,0)
Sleep(100)
ControlClick("Edit Composite","","[CLASS:Button; INSTANCE:2]")
$hwndWin=WinGetHandle("")
$hwndCtrl=ControlGetHandle($hwndWin,"","[CLASS:ScrollBar; INSTANCE:1]")

;how to scroll it down?
;_SendMessage($hwndCtrl,$SBM_GETSCROLLINFO)     <- error, variable not declared

$txtWin=WinGetText($hwndWin)
$txtArray=StringSplit($txtWin,@CRLF)

script chooses 1st item from ListBox, and Clicks Ok button. New window opens. I take handle to this window. This window is made from several edit fields and has ScrollBar. I read handle to Scroll Bar.Because I dont know which edit field contains the information I need I copy all text from window, then I split it and process it (but it doesnt matter, now).

Script works if edit field with the information I need is visible on the screen. But it may happen, that this edit field is not visible on the screen. That's why I need to scroll the window down.

I tried to use functions like _GUIScrollBars_GetScrollInfoMax but I get nothing, fe:

$posMax = _GUIScrollBars_GetScrollInfoMax ( $hwndWin, $SB_VERT )
Edited by pecet
Link to comment
Share on other sites

Sorry, yes I meant handle, here's an example code snippet that could help you:

#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>
Run("Notepad")
Sleep(200)
$hWin = WinGetHandle("[CLASS:Notepad]")
$hCtrl = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")
WinActivate($hCtrl)
For $i = 1 To 40
ControlSend($hWin, "", "Edit1", $i & @LF)
Next
ControlSend($hWin, "", "Edit1", "{PGUP}")
Sleep(500)
$Max = _GUIScrollBars_GetScrollInfoMax($hCtrl, $SB_VERT)
$TrackPos = _GUIScrollBars_GetScrollInfoTrackPos($hCtrl, $SB_VERT)
$PageSize = _GUIScrollBars_GetScrollInfoPage($hCtrl, $SB_VERT)
For $i = $TrackPos To $Max - $PageSize + 1 Step 1
_SendMessage($hCtrl, $WM_VSCROLL, $SB_LINEDOWN, 0)
Sleep(100)
Next
Edited by mpower
Link to comment
Share on other sites

Ok, so in your example scroll bar is "attached" to Edit1 control. Now, I can see, where the problem is.

How can I check to what control scroll bar is attached? Some kind of Parent(?) for my control.

261f2ix.jpg

As you can see the window contains group of labels and edit fields. Can't figure out, where scroll bar is 'attached to'. When I use AutoIt Window Info I can see that both vertical and horizontal bars are disabled for main window.

Edited by pecet
Link to comment
Share on other sites

hmm, what about this, might need to modify slightly to try get parent handle from control handle.

#include <WinAPI.au3>
#include <WindowsConstants.au3>
HotKeySet('{F2}', 'Esc')

Global $tPOINT = DllStructCreate("int X;int Y")



While 1
    Sleep(10)
    $tPOINT= _WinAPI_GetMousePos()

    $hWnd = _WinAPI_WindowFromPoint($tPOINT)
    ; Get the "real" parent window ( also from child of child smile.gif )
    $hWnd2 = _WinAPI_GetAncestor($hWnd,2)
    If Not($hWnd2 = 0) Then $HWnd = $hWnd2
    $title = WinGetTitle($hWnd)
    ; Show Class for Window without Title
    If $title = "" Then $title = "[CLASS:"&_WinAPI_GetClassName($hWnd)&"]"
    ToolTip($title, 0, 0)
   
WEnd

Func Esc()
    Exit
EndFunc  ;==>Esc
Edited by mpower
Link to comment
Share on other sites

  • Solution

Ok, I solved the problem. I discovered that, when I right click on scroll bar, a context menu appears with items like 'Page Up', 'Page Down':)

Anyway, Thanks a lot  mpower, because thanks to this conversation, I have learned a few things.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...