Sign in to follow this  
Followers 0
clicked

When Window Info does not find the control ...

2 posts in this topic

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

$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:

$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 by clicked

Share this post


Link to post
Share on other sites



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).

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