Jump to content
Sign in to follow this  

Get the Window Class

Recommended Posts

Hi All,

I'm looking to get the window class (see the autoIT INfo tool below). I have a handle on the window and it's title, I'd like to get the class name for the window programmatically! I can't find out where to get it at. Anyone got this laying around on their computer?

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: AutoIt Forums -> Posting New Topic - Mozilla Firefox

Class: MozillaUIWindowClass <<< ---- (I want to get this info)

Size: X: 42 Y: 0 W: 970 H: 738

Share this post

Link to post
Share on other sites

Try this:

$list = WinList()
for $x = 1 to $list[0][0]
    ;filter out empty titles
    If $list[$x][0] <> "" Then
        ConsoleWrite(StringFormat("Title:%s  Classname:%s",$list[$x][0],_GetClassName($list[$x][1])&@LF))

; Function Name:    _GetClassName
; Description:        get the classname of a ctrl or window
; Parameter(s):    $nCtrl         the ctrlId of to get classname for. 
; Requirement(s):        
; Return Value(s):    Classname or 0 on failure
; User CallTip:    
; Author(s):        Stephen Podhajecki <gehossafats at netmdc.com/>
; Note(s):            Strips trailing numbers from classname.
Func _GetClassName($nCtrl)
    If Not IsHWnd($nCtrl) then $nCtrl = HWnd($nCtrl)
    Local $struct = DllStructCreate("char[128]"),$classname = 0
    $ret = DllCall("user32.dll","int","GetClassName","hwnd",$nCtrl,"ptr",DllStructGetPtr($struct),"int",DllStructGetSize($struct))
    If IsArray($ret) Then
        $classname = DllStructGetData($struct,1)
        While (StringIsDigit(StringRight($classname,1)))
            $classname = StringTrimRight($classname,1)
    $struct =0 
    Return $classname
oÝ÷ Øw«z+,¢g¨~Ø^¢ëiºÖ®¶­s`¥FFÆS¥66DRçFW&f6R6Æ76æÖS¤WFôBc2uT¥FFÆS¤Æ76ôBÕ67&VVâ&÷W"6Æ76æÖS¤WFôBc2uT¥FFÆS¤WFôBc26Æ76æÖS¤WFôB`¥FFÆS¤WFôBc26Æ76æÖS¤WFôB`¥FFÆS¤3¢b3#µ&öw&ÒfÆW2b3#´WFôC2b3#µ67&G2b3#¶6Æ76æÖWFW7BæS2Ò66DR³RöbUÒ6Æ76æÖS¥66DUvæF÷p¥FFÆS¤WFôBf÷'V×2ÒfwC²&WÇærâvWBFRvæF÷r6Æ72ÒÖ÷¦ÆÆf&Vf÷6Æ76æÖS¤Ö÷¦ÆÆTvæF÷t6Æ70¥FFÆS¤WFôBVÇ6Æ76æÖS¤&Vç@¥FFÆS¤Ô46öÖÖæBæFÆærvæF÷r6Æ76æÖS¢0¥FFÆS¤WFôC4VÇ6Æ76æÖS¤WFôC2VÇ¥FFÆS¤3¢b3#µtäDõu2b3#·77FVÓ3"6Æ76æÖS¤6&æWEt6Æ70¥FFÆS¤Ô46öÖÖæBæFÆærvæF÷r6Æ76æÖS¢0¥FFÆS¤WFôBc26Æ76æÖS¤WFôB`¥FFÆS¤æWG66TF7F6væB6Æ76æÖS¦ç5FööƶD6Æ70¥FFÆS¥4ôÓ¤WfVçE&V6VfW"6Æ76æÖS¥4ôÓ¤WfVçEvæF÷p¥FFÆS¤F&V7F÷$WFVç6öâ6Æ76æÖS¤F&V7F÷$WFVç6öà¥FFÆS¥66DUõ6ævÆUF&VDWFVç6öåôF7F6W"6Æ76æÖS¥7FF0¥FFÆS¤3¢b3#²6Æ76æÖS¤6&æWEt6Æ70¥FFÆS¥6V&6&W7VÇG26Æ76æÖS¤6&æWEt6Æ70¥FFÆS¥7æW&wFW6²6Æ76æÖS¥7æW&wFW6°¥FFÆS¥&öw&ÒÖævW"6Æ76æÖS¥&övÖà

Edit: I did not try passing the handle to WinGetClassList builtin function. I use this function mostly as a replacement for vb's TypeOf function.

Edited by eltorro

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...