Jump to content
Sign in to follow this  

Autoit Spy identifies one control as many

Recommended Posts

:whistle: Sometimes the Spy reports multiple controls when I inspect a single control on form that I want to automate.

Latest incident: a checkbox is identified either as Button89 or Button62 or even Button98.. as I hover over the control. Seems like Button62 is associated with the lower half of the control, while the others contend for the upper-half somehow!

When I actually check/uncheck the checkbox, it sometimes gets identified as Button62, sometimes as Button89. Doesn't appear to make a difference whether I'm over the box-portion of the control or over the label-portion.

Any ideas? B)

Share this post

Link to post
Share on other sites

Use another program to get the button class. I like a standalone program called Enabler; it's site is gone, but you can get it here

Run the program, then right-click on its "Class" caption, and drag the now-crosshair-shaped mouse to your mystery checkbox.

Hope that helps

Sometimes Enabler has problems getting a hold of controls that are in frames, but there are other spy programs that you can try....

Edited 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!

Share this post

Link to post
Share on other sites

Aha! Here's what is happening ..

The checkbox control is on a tabbed dialog. Seems like my Spy is reporting whatever it can see that is "under the mouse" .. even when the controls that it sees are on other tabs/layers (or invisible or whatever)!

So it's not exactly lying - but it certainly isn't telling the truth. Mind you, they say the truth is relative. B)

Here's a workaround that might come in useful:

;Name of the dialog..
    $sTitle = "VirusScan On-Access Scan Properties"
;set focus using the control's hotkey assignment..
;Interrogate it for it's name..
    $sCtl = ControlGetFocus($sTitle ,"") 
;Aim a checkmark at it
    ControlCommand($sTitle, "", $sCtl, "Check" ,"")

BTW .. turns out the control is actually named Button107 - lol!

Any chance of training the Spy to be able to distinguish between targets on a tabbed dialog? :whistle:

Share this post

Link to post
Share on other sites

Thanks CyberSlug .. neat little tool - I like the way it highlights exactly what it's reporting on.

But as you say, it can't seem to find the contorls in frames. Thanks anyway .. and I hope the workaround above helps anyone else trying to automate such dialogs.

Meantime .. if anyone has recommendations for reliable spies .. or there is a chance of enhancing our built-in spy, I'm listening :whistle:

Share this post

Link to post
Share on other sites

Hmmm .. my quick-fix proved unreliable for some reason: sometimes the hotkey to set focus at a widget doesn't let the ControlGetFocus work properly. B)

However .. here's a little tool I came up with to help identify selected widgets and list them to the clipboard :whistle:

;Hitman.au3 - for when you can't find a spy to do the dirty work =o)

;Get the user ready
    $sX = "Click [OK] here: when you have started the application" & @CRLF
    $sX = $sX & "whose form you wish to interrogate for widget names." & @CRLF & @CRLF
    $sX = $sX & "A countdown will then start, to give you time to select the first" & @CRLF
    $sX = $sX & "widget to interrogate."
    MsgBox(4096 + 64, @ScriptName, $sX) 

;Start a countdown for the user to find his target window
    ProgressOn("Quick! Find your target window","Counting down..")
    For $k = 0 to 4
        ProgressSet(100 - 20 * $k)
    $sTitle = WinGetTitle("","")   ;whatever has focus by now
;Loop around and hit selected targets till assignment is terminated by user
    $sFinalClip = ""
       ;Carry out the hit
        WinActivate($sTitle, "")
        $sCtl = ControlGetFocus( $sTitle ,"")
        $sCtlText = ControlGetText($sTitle,"", $sCtl)
       ;Record widget name to the clipboard
       ;Build the final solution - here are two alternative formats
;        $sFinalClip = $sFinalClip & $sCtl & @TAB & "; " & $sCtlText & @CRLF
        $sFinalClip = $sFinalClip & ";Widget = [" & $sCtlText & "]" & @CRLF & @TAB & $sCtl & @CRLF
       ;Report on it and ready the user for his next assignment
        $sX = "Window Title = " & $sTitle
        $sX = $sX & @CRLF & "Widget name = " & $sCtl & " (has been copied to clipboard)"
        $sX = $sX & @CRLF & @CRLF & "Select another widget there and press [OK],"
        $sX = $sX & @CRLF & "or press [Cancel] to quit."
    until MsgBox (4096 + 64 + 1, @ScriptName, $sX) = 2;2=CANCEL
;Say goodbye
    $sX = "This journal of hits has been copied to the clipboard:" & @CRLF & @CRLF
    $sX = $sX & $sFinalClip
    MsgBox (4096 + 64, @ScriptName, $sX)

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