pecet Posted March 11, 2015 Posted March 11, 2015 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?
mpower Posted March 11, 2015 Posted March 11, 2015 You will need to post some more code, otherwise its a bit hard to figure out what exactly you are trying to do, even with your explanation.
pecet Posted March 11, 2015 Author Posted March 11, 2015 (edited) $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 March 11, 2015 by pecet
mpower Posted March 11, 2015 Posted March 11, 2015 hmm when you use $hwndCtrl=ControlGetHandle($hwndWin,"","[CLASS:ScrollBar; INSTANCE:1]") do you get a ControlID ?
pecet Posted March 11, 2015 Author Posted March 11, 2015 I get handle (don't know real difference between handle and ID - I know only that handle changes every time, and ID can be constant?).
mpower Posted March 11, 2015 Posted March 11, 2015 (edited) 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 March 11, 2015 by mpower
pecet Posted March 11, 2015 Author Posted March 11, 2015 (edited) 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. 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 March 11, 2015 by pecet
mpower Posted March 11, 2015 Posted March 11, 2015 (edited) 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 March 11, 2015 by mpower
Solution pecet Posted March 12, 2015 Author Solution Posted March 12, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now