Jump to content

COM error handling works randomly


autoking
 Share

Recommended Posts

Hi. my com error handling works randomly, Like every second time it cathes if there's a error, if it couldn't connect to my site.

Global $url = IniRead(@scriptdir & "\file.exe", 'data', 'data', 'Null')
global $f = FileOpen(@TempDir & "\file.txt") ;upload 1
$read = FileRead($f)
$data = "Log=" & $read
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", $url, False)
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
$oHTTP.SetRequestHeader("Referrer", "http://www.yahoo.com")
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send($data)
;$oReceived = $oHTTP.ResponseText
;MsgBox(4096, "", "file.exe have been generated")
FileClose($f)



Case $show



Case $help


EndSwitch
WEnd

Func MyErrFunc()
MsgBox(4096, "", "A test log could not be send - please ensure you have uploaded & defined the right path.")
Endfunc
Link to comment
Share on other sites

COM error handling in AutoIt is quite simple.... the script just stops..... Unless you use your own error handling. After a COM call use code like..

if @error then
msgbox(0, "bla", "tell me something")
endif

Tho, the actions taken can be whatever you wish. In my scripts I code verbose log writing, so errors are recorded in external logs (which I designed). Ayways, do a search in the AutoIt help and you'll find COM Reference, there's some good stuff in there.

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...