Jump to content

get ID or ClassNN for a control/button?


 Share

Recommended Posts

I could only get this to work with an exact match.

Run("calc.exe")
WinWaitActive("Calculator")

;Enter 9999 into calculator
For $x = 0 to 3
    ControlClick("Calculator", "", "[CLASS:Button; TEXT:9;]")
Next

;Click backspace button 4 times
For $x = 0 to 3
    ControlClick("Calculator", "", "[CLASS:Button; TEXT:Backspace;]")
Next

EDIT: Need like CtrlMatchMode or something.

Edited by weaponx
Link to comment
Share on other sites

What I really need to do is send a ControlClick command to a button, but some of the text on that button changes in my tests. I've tried this:

ControlClick("title", "text", "[CLASS:Button; TEXT:&FOO]")

Unfortunately that requires the exact text on the button ("FOO" in this case).

Is there any way to iterate through the controls on a window?

Edited by HotSauce
Link to comment
Share on other sites

Seems like a hack, but my problem is solved. This searches for visible buttons that contain the text I'm looking for, and it unchecks that (checkbox) button if it is checked.

$title = "Marshmallow Fluff Installer"
$text = ""
$checktext = "I understand by leaving this box checked I will be allowing the Marshmallow Fluff Overlord to "
$i = 1
While Not @error = 1 
    If ControlCommand($title, $text, "Button" & $i, "IsVisible", "") Then
        $text = ControlGetText($title, $text, "Button" & $i)
        If StringInStr($text, $checktext) Then
            If ControlCommand($title, $text, "Button" & $i, "IsChecked", "") Then
                ControlFocus($title, $text, "Button" & $i)
                ControlClick($title, $text, "Button" & $i)
            EndIf
            MsgBox(64, "Unchecked", $text)
        EndIf
    EndIf
    $i += 1
WEnd

Please let me know if there is an easier/better way!

Link to comment
Share on other sites

Doesn't seem like much of hack to me. I was thinking along the same lines. I'm kind of surprised there isn't a builtin function like winlist to get an array of the controls. My guess is that it's because it would be too complex of an array.

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