Sign in to follow this  
Followers 0
marko29

Find HWND handle that has generic class name and no title

Help me improve   2 members have voted

  1. 1. Was this useful?

    • Yes
    • No, you suck
      0

Please sign in or register to vote in this poll.

5 posts in this topic

#1 ·  Posted (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 by marko29

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
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
Sign in to follow this  
Followers 0