cfay Posted June 3, 2009 Share Posted June 3, 2009 Hello All, I have written a fairly lengthy script that includes quite a few WinWaitActive commands. I had not added a timeout to any of the commands (which wouldn't be too big a deal to have to go back and do), but I am wondering if there is a way to have the script goto an onerror function (gathers some debug info before exiting) after the WinWait Timeout has been reached. I am looking for a way to NOT have to do the following for each instance: $Result = WinWaitActive("WINDOW TITLE", "WINDOW TEXT ") If ($Result = 0) Then _FileWriteLog($TmpFolder & "\Install.log", "ERROR: TIMEOUT: Waiting For Window FAILED") onerror() Exit Else _FileWriteLog($TmpFolder & "\Install.log", "Window Found") EndIf Thanks in Advance, -Chris Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 3, 2009 Share Posted June 3, 2009 (edited) Hello All, I have written a fairly lengthy script that includes quite a few WinWaitActive commands. I had not added a timeout to any of the commands (which wouldn't be too big a deal to have to go back and do), but I am wondering if there is a way to have the script goto an onerror function (gathers some debug info before exiting) after the WinWait Timeout has been reached. I am looking for a way to NOT have to do the following for each instance: $Result = WinWaitActive("WINDOW TITLE", "WINDOW TEXT ") If ($Result = 0) Then _FileWriteLog($TmpFolder & "\Install.log", "ERROR: TIMEOUT: Waiting For Window FAILED") onerror() Exit Else _FileWriteLog($TmpFolder & "\Install.log", "Window Found") EndIf Thanks in Advance, -Chris Just turn it into a UDF and use that in place of WinWaitActive(): _WinExpected("WINDOW TITLE", "WINDOW TEXT ", 120); Wait max 2min. Func _WinExpected($sWinTitle, $sWinText, $iTimeout = 30) ; Default timeout = 30sec ; $TmpFolder must be globally declared Local $Result = WinWaitActive($sWinTitle, $sWinText, $iTimeout) If ($Result = 0) Then _FileWriteLog($TmpFolder & "\Install.log", "ERROR: TIMEOUT: Waiting For Window FAILED: " & $sWinTitle & "; " & $sWinText) onerror() Exit Else _FileWriteLog($TmpFolder & "\Install.log", "Window found active: " & $sWinTitle & "; " & $sWinText) Return 1 EndIf EndFunc ;==>_WinExpected Edited June 3, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
cfay Posted June 3, 2009 Author Share Posted June 3, 2009 Very Clever Thank you that is a great idea, I will try that. Thanks again, -Chris 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