Jump to content

_WinGetNumberedClassList()


LxP
 Share

Recommended Posts

I generally find that WinGetClassList() isn't as featured as I would like it. I have wanted on more than one occasion to enumerate a list of controls from a window and then manipulate them via a loop. Obviously this would be best done via an array and not an @LF-delimited string.

_WinGetNumberedClassList() will retrieve classes from a window and append the appropriate NN suffix to the results, which can then be used wherever a control ID is expected. The data can be returned in exactly the same format as WinGetClassList() or as an array according to your convenience.

This code has been tested with AutoIt v3.1.1.82. The example script demonstrates how to read all text from a window.

 

; ==============================================================================
;
; Function Name:    _WinGetNumberedClassList()
; Description:      Retrieves the classes from a window in a format that can be
;                   used where control IDs are expected.
; Parameter(s):     $sTitle    -- The title of the window to read.
;                   $sText     -- [Optional] The text of the window to read.
;                   $fAsArray  -- [Optional] Boolean to determine whether to
;                                 return the result as an array (defaults to
;                                 WinGetClassList() behaviour, i.e. False).
; Requirement(s):   None
; Return Value(s):  On success -- $fAsArray = True: Returns a list of enumerated
;                                    ClassNameNNs where the first element is a
;                                    count of entries.
;                                 $fAsArray = False: Returns an @LF-delimited
;                                    list (exactly like WinGetClassList()).
;                   On failure -- Returns an empty string or array (depending on
;                                 the requested type) and sets @Error to 1 if no
;                                 window matches the specified criteria.
; Author(s):        Alex Peters (LxP)
;
; ==============================================================================

Download: _WinGetNumberedClassList.au3_WinGetNumberedClassList.txt_WinGetNumberedClassList_Example.au3

 

I hope that others will find this useful. Any feedback whatsoever is encouraged!

 

Edit: This UDF probably should have been named something like _WinGetControlIDs() instead. Probably too late now...?

 

v1.0 (22/Oct/2005):

  • Initial release
Edited by LxP
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...