edgariyu Posted March 26, 2011 Share Posted March 26, 2011 Hi everyone!I would like to know how could i make not stop a script if something happens. I'm using the funcion:$WinHttpReq = ObjCreate("winhttp.winhttprequest.5.1") ;Realizamos la peticion HTTP $WinHttpReq.open("GET",$page) $WinHttpReq.send()and the problem i have is that if the page i'm opening is down or something goes wrong the script stops. I know that the answer is in a Object handler and it's something like:Global $g_eventerror = 0 $WinHttpReq = ObjCreate("winhttp.winhttprequest.5.1") ;Realizamos la peticion HTTP $WinHttpReq.open("GET",$page) if $g_eventerror = 1 then $WinHttpReq.send() else consolewrite("Error on page") endif Func MyErrFunc() local $HexNumber= hex($oMyError.number,8) If $HexNumber<> (80020009 or 80070005) Then ConsoleWrite("On Load error") $g_eventerror = 1 ; something to check for when this function returns EndIf Endfuncbut i'm missing something because i don't know how to get the concrete error number to handel the error. The function $WinHttpReq.send() sometimes gets an error (The requested action with this object has failed) and i don't know how to make the script not to stop. I've read the object page but still continue with doubts.Is there anyone with experience dealing with this objects reference that cound help me to solve this problem?Thanks a lot!! Link to comment Share on other sites More sharing options...
AutoBert Posted March 26, 2011 Share Posted March 26, 2011 Have a look in the help file while ... wend / do ... until Link to comment Share on other sites More sharing options...
trancexx Posted March 26, 2011 Share Posted March 26, 2011 Have a look in the help file while ... wend / do ... until You are over 13, right? @edgariyu, try something like this: ; Error object Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ; Nothing EndFunc ; Main code: Global $oWinHttpReq = ObjCreate("winhttp.winhttprequest.5.1") $oWinHttpReq.Open("GET", "http://something to cause error") $oWinHttpReq.Send() If $oError.number Then MsgBox(48, "Error", "Error sending request. Number is 0x" & Hex($oError.number, 8)) $oError.clear() EndIf ConsoleWrite("Still alive!" & @CRLF) ; ...whatever here... ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
edgariyu Posted March 27, 2011 Author Share Posted March 27, 2011 Thanks for the answer! I'll try what you suggest 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