Jump to content
Sign in to follow this  

How to not stop a script?

Recommended Posts

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

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
if $g_eventerror = 1 then
  consolewrite("Error on page")

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 

but 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!!

Share this post

Link to post
Share on other sites

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

; Main code:
Global $oWinHttpReq = ObjCreate("winhttp.winhttprequest.5.1")
$oWinHttpReq.Open("GET", "http://something to cause error")

If $oError.number Then
    MsgBox(48, "Error", "Error sending request. Number is 0x" & Hex($oError.number, 8))

ConsoleWrite("Still alive!" & @CRLF)
; ...whatever here...




Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...