#include-once #include #include "log4a.au3" ; Create a hot key. I'm using the "Pause/Break" key typically located near the number pad on the keyboard. The keycode for this key is simply "{PAUSE}" HotKeySet("{PAUSE}", "_togglePause") ; Create a Boolean (True of False variable) to tell your program whether or not your program is paused or unpaused. Set it equal to 'False' so the script is running by default. Global $isPaused = False ; #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 Forms text to match ; $ctrl - Class of Copntrol ; $ctrltxt - Text of the Control you search for ; $timeout - [Optional] Timeout, Default = 0, millisecond timer ; $delayafter - [Optional] Time to delay after operation carried out ; Return values .: None ; Author ........: Peter Martin ; Modified ......: ; Remarks .......: Waits for each button indefinatly. ; Logger found here: https://www.autoitscript.com/forum/topic/156196-log4a-a-logging-udf/ ; Related .......: ; Link ..........: ; Example(s) ....: _checkClickCtrl ('[CLASS:#32770]', 'ApplicationX - InstallShield Wizard', '[CLASS:Button; INSTANCE:1]', , '&Next >' 5000, 0) ; _checkClickCtrl($formclass, $text, $button2, $TD_BTN_REMOVE, 0, 0) ; _checkClickCtrl($formclass, $text, $button3, $TD_BTN_NEXT, 0, 500) ; _checkClickCtrl($formclass, $text, $button1, $TD_BTN_YES, 0, 0) ; _checkClickCtrl($formclass, $text, $button4, $TD_BTN_FINISH, 0, 0) ; =============================================================================================================================== 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('Control [:' & $ctrl & '] Clicked') ControlClick($formclass, '', $ctrl) If ($delayafter > 0) Then Sleep($delayafter) EndIf _log4a_Info("ExitLoop:Normal - " & $ctrl) ExitLoop EndIf EndIf EndIf WEnd _log4a_Info("_checkClickCtrl():End") EndFunc ;==>_checkClickCtrl ; #FUNCTION# ==================================================================================================================== ; Name ..........: _togglePause ; Description ...: Pause your scripts during execution for debug ; Syntax ........: togglePause () ; Parameters ....: None ; Return values .: None ; Author ........: root ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; ===============================================================================================================================; Create the togglePause function to stop/start the script Func _togglePause () ; When this function is initiated, the code on the next line 'toggles' the variable to True/False. If the script is unpaused (the $isPaused variable is set to 'False') then the next line will change it to 'True' and vice versa. $isPaused = NOT $isPaused ; Create a while loop to stall the program ; The line below is the same thing as "While $isPaused == True" While $isPaused ; This code will run constantly until the $isPaused variable is set to 'True'. To make the script do nothing, simply add a sleep command. Sleep(100) WEnd EndFunc