Aceguy Posted May 21, 2009 Share Posted May 21, 2009 hi im trying to create a func that clicks a control if its there.... ie. a button... if not there, wait.? something like func _cwc($title,$id,$txt) do $rt_txt=ControlGetText($title,"",$id) sleep(250) until $rt_txt=$txt sleep(100) ControlClick($title,$txt,$id,"left",1) sleep(100) EndFunc anyone know of a betterway. or is this ok.? [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 21, 2009 Moderators Share Posted May 21, 2009 (edited) Func _ControlWait($h_wnd, $s_text, $v_control, $i_timeout = 0) Local $h_control = 0, $i_timer = TimerInit() While Not $h_control $h_control = ControlGetHandle($h_wnd, $s_text, $v_control) If $i_timeout And TimerDiff($i_timer) / 1000 >= $i_timeout Then Return SetError(1, 0, 0) EndIf Sleep(250) WEnd Return $h_control EndFunc Edit: Just in case you're confused on how to use it: Global $h_c = _ControlWait("My Window Handle/Title", "Text If Any", "ControlID or Other Identifier") ControlClick("My Window Handle/Title", "Text If Any", $h_c) Edit2: Looking at your code, I can see you're probably not familiar with how to use the special description parameters. If you're waiting for a control, have no idea what its ID or ClassNameNN is going to be, and the only thing you do know is it's a button, and what text will show. You may want to try something like: Global = $s_text_to_wait_for = "ButtonIsHereNow" Global $h_c = _ControlWait("My Window Handle/Title", "Text If Any", "[CLASS:Button; TEXT:" & $s_text_to_wait_for & "]") ControlClick("My Window Handle/Title", "Text If Any", $h_c) You can find these special features for controls in the help file: Content Tab -> Using AutoIt -> Controls Edited May 21, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Aceguy Posted May 21, 2009 Author Share Posted May 21, 2009 WOW fast, and superb, ty [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 21, 2009 Moderators Share Posted May 21, 2009 WOW fast, and superb, tyNP, be sure to see the last edit with special descriptors. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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