clicked Posted April 20, 2011 Share Posted April 20, 2011 (edited) Window Info is a really nice tool. If it always finds all the controls on your dialog for you, then read no further. I have found that Window Info does not always find nested controls e.g. sometimes inside group boxes. But I recently discovered that ControlCommand can find standard Windows controls that Window Info cannot find. All you need is the control ID. So, this suggests a simple script to report control ID's. The following script stores the current value of a bunch of controls, and then rechecks them every second or so. If anything changed (e.g. because you changed it) then it tells you the control ID that changed. To use: run the script, tell it the window title, the number of controls to scan, and change the control (for listboxes, select a different listitem; for checkboxes, check or uncheck it). I apologize in advance for the sloppy coding. Here is code to find ListBox controls: expandcollapse popup$winName = InputBox ( "ListBox Finder", "Enter Dialog Box Title" ) local $winActive = WinActivate ( $winName ) if $winActive = 0 Then msgbox ( 0, "Window Not Found", "Specified window name not found." ) Exit EndIf $maxControls = InputBox ( "ListBox Finder", "Enter Max Number of Controls to Search:" ) Local $results[$maxControls + 1] ; First pass for $index = 1 to $maxControls $results[$index] = ControlCommand ( $winName, "", "ListBox" & $index, "GetCurrentSelection", "") Next ; Now loop while True for $index = 1 to $maxControls local $currVal = ControlCommand ( $winName, "", "ListBox" & $index, "GetCurrentSelection", "") if ( $currVal <> $results[$index]) Then if WinActivate($winname) = 0 then Exit ; exit if the window is gone EndIf msgbox (0, "Different!", "ListBox" & $index & @CR & $currVal) $results[$index] = ControlCommand ( $winName, "", "ListBox" & $index, "GetCurrentSelection", "") EndIf Next sleep (10) if WinActivate($winname) = 0 then Exit EndIf WEnd Here is code for CheckBoxes: expandcollapse popup$winName = InputBox ( "CheckBox Finder", "Enter Dialog Box Title" ) local $winActive = WinActivate ( $winName ) if $winActive = 0 Then msgbox ( 0, "Window Not Found", "Specified window name not found." ) Exit EndIf $maxControls = InputBox ( "CheckBox Finder", "Enter Max Number of Controls to Search:" ) Local $results[$maxControls + 1] ; First pass for $index = 1 to $maxControls $results[$index] = ControlCommand ( $winName, "", "Button" & $index, "IsChecked", "") Next ; Now loop while True for $index = 1 to $maxControls $currVal = ControlCommand ( $winName, "", "Button" & $index, "IsChecked", "") if ( $currVal <> $results[$index]) Then if WinActivate($winname) = 0 then Exit ; exit if the window is gone EndIf msgbox (0, "Different!", "Button" & $index & @CR & $currVal) $results[$index] = ControlCommand ( $winName, "", "Button" & $index, "IsChecked", "") EndIf Next sleep (10) if WinActivate($winname) = 0 then Exit EndIf WEnd On my machine, the script can loop over approx 30-40 control IDs in a second. If you have hundreds, then you need to click slowly. Edited April 21, 2011 by clicked Link to comment Share on other sites More sharing options...
clicked Posted January 8, 2012 Author Share Posted January 8, 2012 The new Window Info tool in 3.3.8.0 (with the ability to turn off Use Spy++ Control) now finds all of my controls, so I have retired this little script (not that anybody knew what the hell I was trying to do). 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