#include-once #include #include "log4a.au3" #RequireAdmin ; #FUNCTION# ==================================================================================================================== ; Name ..........: _checkClickCtrl ; Description ...: Automatically wait for a control before clicking on it ; Syntax ........: _checkClickCtrl($formclass, $text, $ctrl, $ctrltxt[, $timeout = 0[, $delayafter = 0]]) ; Parameters ....: $formclass - a floating point value. ; $text - a dll struct value. ; $ctrl - an unknown value. ; $ctrltxt - an unknown value. ; $timeout - [optional] a dll struct value. Default is 0. ; $delayafter - [optional] a binary variant value. Default is 0. ; Return values .: None ; Author ........: Your Name ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== 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) Local $return = ControlClick($formclass, '', $ctrl) If ($return) Then _log4a_Info('Control ' & $ctrl & ' return code success: ' & $return) If ($delayafter > 0) Then Sleep($delayafter) EndIf Else _log4a_Info('Control ' & $ctrl & ' return code error: ' & $return) EndIf _log4a_Info("ExitLoop:Normal - " & $ctrl) ExitLoop EndIf EndIf EndIf WEnd _log4a_Info("_checkClickCtrl():End") EndFunc ;==>_checkClickCtrl