marko29 Posted January 10, 2011 Share Posted January 10, 2011 (edited) #include <Array.au3> Dim $windows_searched[10] ;Make array as big as windows you need to find $arrayposition = 0 ; needed to know where to put the next hwnd found $lista = WinList("[CLASS:tooltips_class32]") ; this is the basic class name that made our window we need to find but plenty of other windows could also use this, so we do for loop bellow... _ArrayDisplay($lista, "Have " & $lista[0][0] & " Windows that exist") ; Lets see what we got so far...including bunch of windows we dont need. For $wnd = 1 To $lista[0][0] -1 ;$lista[0][0] displays how many classes we got, so this is how many times we need to iterate in the loop $text = WinGetClassList($lista[$wnd][1]) ; get the class list of each window in the list so we can check if that window has child-classes that will tell us if thats the window we need! If (StringInStr($text, "VBFloatingPalette")) = 1 Then ; The window i was looking for in this example had VBFloatingPalette class as the child. $windows_searched[$arrayposition] = $lista[$wnd][1] ; So if the classlist with VBFloatingPalette in the current row matches with VBFloatingPalette i simply add the hwnd handle to my array! $arrayposition += 1 ; move array one position forward for next window with same class as child. MsgBox(0, "Window Found", "Pointer: "&$lista[$wnd][1] &" With Searched Classes: "&$text) EndIf Next _ArrayDisplay($windows_searched) ; Show what we found Perhaps you find it useful, just solved this problem that gave me some headaches lately so i figure maybe someone else could run into it. Also there are probably more validations that could be added but this should be enough imo. I only had one child-class as identifier of a hwnd but you could easily modify StringInStr to validate it for as many classes you need. Edited January 10, 2011 by marko29 Link to comment Share on other sites More sharing options...
Newb Posted January 14, 2011 Share Posted January 14, 2011 An example on how to use? I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
zain Posted February 9, 2011 Share Posted February 9, 2011 #include <Array.au3> Dim $windows_searched[10] ;Make array as big as windows you need to find $arrayposition = 0 ; needed to know where to put the next hwnd found $lista = WinList("[CLASS:tooltips_class32]") ; this is the basic class name that made our window we need to find but plenty of other windows could also use this, so we do for loop bellow... _ArrayDisplay($lista, "Have " & $lista[0][0] & " Windows that exist") ; Lets see what we got so far...including bunch of windows we dont need. For $wnd = 1 To $lista[0][0] -1 ;$lista[0][0] displays how many classes we got, so this is how many times we need to iterate in the loop $text = WinGetClassList($lista[$wnd][1]) ; get the class list of each window in the list so we can check if that window has child-classes that will tell us if thats the window we need! If (StringInStr($text, "VBFloatingPalette")) = 1 Then ; The window i was looking for in this example had VBFloatingPalette class as the child. $windows_searched[$arrayposition] = $lista[$wnd][1] ; So if the classlist with VBFloatingPalette in the current row matches with VBFloatingPalette i simply add the hwnd handle to my array! $arrayposition += 1 ; move array one position forward for next window with same class as child. MsgBox(0, "Window Found", "Pointer: "&$lista[$wnd][1] &" With Searched Classes: "&$text) EndIf Next _ArrayDisplay($windows_searched) ; Show what we found Perhaps you find it useful, just solved this problem that gave me some headaches lately so i figure maybe someone else could run into it. Also there are probably more validations that could be added but this should be enough imo. I only had one child-class as identifier of a hwnd but you could easily modify StringInStr to validate it for as many classes you need. Fine ! i have stuck into a situation in which i have no text or title of window Can you tell me how to access its controls. this is name of class as shown from auto info WindowsForms10.window.8.app.0.33c0d9d Link to comment Share on other sites More sharing options...
Mat Posted February 9, 2011 Share Posted February 9, 2011 Thats a .NET control... In which case it has another way of accessing it: NAME. From the helpfile: ControlSetText("My Window", "", "[NAME:textBoxFolder]", "C:\Some\Folder") Here is what winfo said for one of my .NET controls: >>>> Control <<<< Class: WindowsForms10.window.8.app.0.b7ab7b_r13_ad1 Instance: 2 ClassnameNN: WindowsForms10.window.8.app.0.b7ab7b_r13_ad12 Name: toolStrip Advanced (Class): [NAME:toolStrip] The advanced gives it to you as it recommends you use in the code. Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
zain Posted February 11, 2011 Share Posted February 11, 2011 Thats a .NET control... In which case it has another way of accessing it: NAME. From the helpfile: ControlSetText("My Window", "", "[NAME:textBoxFolder]", "C:\Some\Folder") Here is what winfo said for one of my .NET controls: >>>> Control <<<< Class: WindowsForms10.window.8.app.0.b7ab7b_r13_ad1 Instance: 2 ClassnameNN: WindowsForms10.window.8.app.0.b7ab7b_r13_ad12 Name: toolStrip Advanced (Class): [NAME:toolStrip] The advanced gives it to you as it recommends you use in the code. Mat Thanks for Reply! I solved this by $hWnd = WinGetHandle("[ACTIVE]") and once i got handle of window i can access it controls easily. Now i am stuck into a problem.i have to write algo before a text field text change event. Whenever text is changed in this box i will do something in another combo box.how is this possible. Thanks! Link to comment Share on other sites More sharing options...
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