#include #include "log4a.au3" ; #FUNCTION# ==================================================================================================================== ; Name ..........: _checkClickCtrl ; Description ...: Automatically wait for a control to exist. Forever or Limited ; Syntax ........: _checkClickCtrl($formclass, $text, $ctrl, $ctrltxt, $timeout, $delayafter) ; Parameters ....: $formclass - Form Class info. ; $text - Windows text to match ; $ctrl - Class of Copntrol ; $ctrltxt - Text of the Control ; $timeout - Timeout, Default = 0, millisecond timer ; Return values .: None ; Author ........: Peter Martin ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _checkClickCtrl ('[CLASS:#32770]', 'ApplicationX - InstallShield Wizard', '[CLASS:Button; INSTANCE:1]', , '&Next >' 5000) ; Note1 .........; All the arguments should be CONSTANTS for ease of reuse ex. ; _checkClickCtrl($formclass, $text, $button2, $TD_BTN_REMOVE, 0) ; _checkClickCtrl($formclass, $text, $button3, $TD_BTN_NEXT, 0) ; _checkClickCtrl($formclass, $text, $button1, $TD_BTN_YES, 0) ; _checkClickCtrl($formclass, $text, $button4, $TD_BTN_FINISH, 0) ; Waits for each button indefinatly. ; Note2.........; Logger Author(s) .....: Michael Mims (zorphnog) ; the logging script can be obtained here ; https://www.autoitscript.com/forum/topic/156196-log4a-a-logging-udf/ ; =============================================================================================================================== Func _checkClickCtrl($formclass, $text, $ctrl, $ctrltxt, $timeout=0, $delayafter=0) _log4a_Info("_checkClickCtrl():Begin") _log4a_Info("Searching for Formclass: " & $formclass) _log4a_Info("Searching for Text:" & $text) _log4a_Info("Searching for Control:" & $ctrl) _log4a_Info("Searching for Ctrl Txt:" & $ctrltxt) _log4a_Info("Timeout: " & $timeout) _log4a_Info("Time Delay (after click): " & $delayafter) Local $time_run = _Timer_Init() While (1) If WinExists($formclass) Then Local $hCtrl = ControlGetHandle($text, '', $ctrl) If $hCtrl Then If ($timeout > 0) Then _log4a_Info(_Timer_Diff($time_run)) If (_Timer_Diff($time_run) > $timeout) Then _log4a_Info("ExitLoop:Timeout - " & $ctrl) ExitLoop EndIf EndIf Local $hCtrlHandle = ControlGetText($text, '', $ctrl) _log4a_Info("Control Text Search: " & $ctrltxt) _log4a_Info("Control Text Found: " & $hCtrlHandle) If ($hCtrlHandle == $ctrltxt) Then ; we got the handle, so the button is there ; now do whatever you need to do _log4a_Info("Found Formclass: " & $formclass) _log4a_Info("Found Text:" & $text) _log4a_Info("Found Control:" & $ctrl) _log4a_Info("Found Ctrl Txt:" & $ctrltxt) _log4a_Info("Timeout: " & $timeout) _log4a_Info("Time Delay (after click): " & $delayafter) _log4a_Info($ctrl) ControlClick($formclass, '', $ctrl) If (StringLen($delayafter) > 0) Then Sleep($delayafter) EndIf _log4a_Info("ExitLoop:Normal - " & $ctrl) ExitLoop EndIf EndIf EndIf WEnd _log4a_Info("_checkClickCtrl():End") EndFunc ;==>_checkClickCtrl