middae Posted October 26, 2009 Posted October 26, 2009 I have a program - we'll call it ProgA. This program has child windows: ChildA, ChildB, ChildC ChildC has several listboxes. One is resizeable and takes up the maority of the window, and lists a 4 column spread of information. I'm trying to figure out where Column 2 starts in this Listbox. Here's the AutoIt tool info from that window. >>>> Control <<<< Class: AfxWnd80sd Instance: 3 ClassnameNN: AfxWnd80sd3 Advanced (Class): [CLASS:AfxWnd80sd; INSTANCE:3] ID: 1 Text: ListBox Position: 366, 113 Size: 766, 653 ControlClick Coords: 348, 286 Style: 0x50300000 ExStyle: 0x00000000 Handle: 0x000206DE Of Course, instance changes frequently. I thought I'd use ControlGetPos or WinGetPos, but both keep returning errors. WinGetPos gets me the closest, #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <Debug.au3> AutoItSetOption("WinTitleMatchMode","1") AutoItSetOption("WinSearchChildren","1") $hDIM = WinGetHandle("ChildC") $pos = WinGetPos("[CLASS:AfxWnd80sd]","Listbox") Mousemove($pos[0],$pos[1],5) After identifying the Control position, I was planning to move pixel by pixel along X, until my pxchksum (basically OCR the screen) until I find a certain word ("Batch #"). If I can find that, I can click that heading in the listbox, and sort appropriately. I've been stuck on guaranteeing I come up with the correct AfxWnd80sd control. Most of the errors are: control not found, or finding the incorrect AfxWnd80sd controls (there are 3 or 4 at a time in ProgA. "ListBox" as text errors out using both WinGetPos and ControlGetPos.
martin Posted October 26, 2009 Posted October 26, 2009 You will have to set Opt("WinSearchChildren",1) or you will not be able to deal with child windows. Maybe that is the problem. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
PsaltyDS Posted October 26, 2009 Posted October 26, 2009 (edited) Seems like _GuiCtrlListView_GetSubItemRect() gives what you want directly. The WinSearchChildren option is only for the native GUI functions, and wouldn't be required for the UDF functions. Edit: Add demo: #include <GuiListView.au3> #include <Array.au3> $hDIM = WinGetHandle("[CLASS:YourWinClassHere; TITLE:ChildC]") $hLV = ControlGetHandle($hDIM, "", "[CLASS:AfxWnd80sd; INSTANCE:3]") $avRect = _GUICtrlListView_GetSubItemRect($hLV, 0, 2) _ArrayDisplay($avRect, "Item 0/Col 2 Rect") Edited October 26, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
middae Posted October 26, 2009 Author Posted October 26, 2009 You will have to set Opt("WinSearchChildren",1) or you will not be able to deal with child windows. Maybe that is the problem.Isn't that what this does? I thought I read Opt and AutoItSetOption where interchangable?AutoItSetOption("WinSearchChildren","1")And ChildC is being found in ProgA, I use some MouseMoves to move to the top-left corner of it on occasion. It's finding That Listbox of class AfxWnd80sd in ChildC that's a problem. I'm so frustrated. heh.
martin Posted October 26, 2009 Posted October 26, 2009 Isn't that what this does? I thought I read Opt and AutoItSetOption where interchangable?AutoItSetOption("WinSearchChildren","1")And ChildC is being found in ProgA, I use some MouseMoves to move to the top-left corner of it on occasion. It's finding That Listbox of class AfxWnd80sd in ChildC that's a problem. I'm so frustrated. heh. Sorry, I somehow missed that, as I did the point that PsaltyDS made later about it. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
middae Posted October 27, 2009 Author Posted October 27, 2009 (edited) Turns out I had to Enumerate the windows and look for "ListBox " with a space at the end. Unless there's a way to specify a trailing character on the end of a Title? [CLASS:AfxWnd80sd; TITLE:"ListBox "] doesn't work. My Solution: Func FindHDILB() ;Returns "AfxWnd80sd:ListBox " handle $aWindows = _WinAPI_EnumWindows() For $i = 1 To UBound($aWindows) - 1 if $aWindows[$i][1] = "AfxWnd80sd" Then if WinGetTitle($aWindows[$i][0]) = "ListBox " Then $hLB = $aWindows[$i][0] EndIf EndIf Next Return $hLB EndFunc Assigned $hdi = FindHDILB(); then WinGetPos($hdi), and MouseMove($pos[0],$pos[1]) got me where I needed to go. Returned the proper value every time, yippee! Edited October 27, 2009 by middae
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