Jump to content

simple question - http.send


peter123
 Share

Recommended Posts

Hell everyone,

i have a question,

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")

$oHTTP.Open("GET", $link)

$oHTTP.Send()

$HTMLSource = $oHTTP.Responsetext

if i not connected on internet this script give a Error like $oHttp.send()

how can I fix this?

Peter

Link to comment
Share on other sites

Look at the third or fourth post in the MySQL thread in my signature. It has a script for handling COM errors. I'm not sure why you're surprised that that doesn't work when you're not connected to the internet. Anyway, GL.

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

You didn't take the advice to add a COM error handler. Try this:

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler

$link = "http://127.0.0.254" ; bad address to cause error
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open ("GET", $link)
$oHTTP.Send()
If @error Then
    MsgBox(16, "Error", "$oHTTP.Send() returned @error = " & @error & ", and @extended = " & @extended)
    Exit
Else
    $HTMLSource = $oHTTP.Responsetext
    MsgBox(64, "Results", $HTMLSource)
EndIf

; This is my custom error handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    ConsoleWrite("We intercepted a COM Error !" & @LF & _
            "Number is: " & $HexNumber & @LF & _
            "Windescription is: " & $oMyError.windescription & @LF)
    Return SetError(1, $HexNumber) ; something to check for when this function returns
EndFunc   ;==>MyErrFunc

:)

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...