robotgenius Posted May 2, 2006 Share Posted May 2, 2006 Hello- Sorry if this question is basic, but can you dynamically get a list of controls on a window. Of course I can pick out a static window control using autoit window info, but for what I am doing now I need a way to list buttons and other controls on any new window that pops up, and then possibly interact with one of those buttons. The autoit window info tool only works when I can have a chance to create a window by hand ahead of time, and if the controls stay static. There is a winlist function, I am looking for a controllist function also. thanks -Robotgenius Link to comment Share on other sites More sharing options...
CyberSlug Posted May 2, 2006 Share Posted May 2, 2006 (edited) I tweaked some old code I had lying around to enhance AutoIt's WinGetClassList function: expandcollapse popup$title = "Calculator" Run("calc.exe") WinWait($title) MsgBox( 0x0,"Info", _getClasses($title) ) Exit ; This function returns an @LF-separted list of controls on the specified window Func _getClasses($title) ;Get array of each control Local $buttonCount = 0, $editCount = 0, $staticCount = 0, $i Local $classes = StringSplit( WinGetClassList($title) , @LF) Local $classIDs[$classes[0]+1] $classIDs[0] = $classes[0] For $i = 1 to $classes[0] Select Case $classes[$i] = "Button" $buttonCount = $buttonCount + 1 $classIDs[$i] = $classes[$i] & $buttonCount Case $classes[$i] = "Edit" $editCount = $editCount + 1 $classIDs[$i] = $classes[$i] & $editCount $classes[$i] = "Input" Case $classes[$i] = "Static" $staticCount = $staticCount + 1 $classIDs[$i] = $classes[$i] & $staticCount $classes[$i] = "Label" Case Else If $classes[$i] <> "" Then $classIDs[$i] = $classes[$i] & "?" EndSelect Next ;Display the results Local $output = "" For $i = 1 to $classIDs[0] $output = $output & $classIDs[$i] & @LF Next Return $output EndFunc Edited May 2, 2006 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
robotgenius Posted May 2, 2006 Author Share Posted May 2, 2006 Hello- That seems to do what I need. Thank for the reply.thanksRobotgeniusI tweaked some old code I had lying around to enhance AutoIt's WinGetClassList function: 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