HotSauce Posted October 17, 2007 Share Posted October 17, 2007 Given the text of a button (either all or partial), is it possible to get the ID or ClassNN for that button? (e.g. 'Button1') Link to comment Share on other sites More sharing options...
LarryDalooza Posted October 17, 2007 Share Posted October 17, 2007 Exact text?... Partial Text? Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
weaponx Posted October 17, 2007 Share Posted October 17, 2007 (edited) 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 October 17, 2007 by weaponx Link to comment Share on other sites More sharing options...
HotSauce Posted October 17, 2007 Author Share Posted October 17, 2007 (edited) 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 October 17, 2007 by HotSauce Link to comment Share on other sites More sharing options...
HotSauce Posted October 17, 2007 Author Share Posted October 17, 2007 It looks like I can use ControlGetText on buttons. The problem is when I iterate through the ButtonNN controls starting from NN = 1, I'm getting buttons from all of the app's dialog windows (previous and next). Link to comment Share on other sites More sharing options...
HotSauce Posted October 17, 2007 Author Share Posted October 17, 2007 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 More sharing options...
weaponx Posted October 17, 2007 Share Posted October 17, 2007 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 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