Sign in to follow this  
Followers 0
suthers

!>AutoIT3.exe ended.rc:-1073741819 Crash

8 posts in this topic

Hi All,

I'm trying my first attempt to respond to a COM object event.

The object is winhttp.winhttprequest.5.1

The event is OnResponseFinished

Documentation on the object is at http://msdn.microsoft.com/en-us/library/aa384106(VS.85).aspx

The following code runs fine to set up the object & start the download in asynchronous mode.

However, when the download ends and (I presume) the event is fired AutoIT crashes with the return code of 1073741819 (as reported by SciTE)

Any suggestions as to where I've gone wrong?

Much Thanks

Bill

$SourceURL = "http://kitco.com/images/live/gold.gif"
$TempFile = @TempDir & "\AutoITTempWinTHHPRequest.gif"
$COMError = "no"
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; COM error handler 
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ;set up HTTP Request Object
$oMyEventFinished = ObjEvent($oHTTP, "WinHTTPEvent_") ; Event handler
$oHTTP.Open("GET", $SourceURL, 1)
$COMError = "no" ; flag for com error experienced
$Ended_b = 0 ; flag for download in progress
$oHTTP.Send()
SplashTextOn (@ScriptName,"Downloading" & @CRLF & $SourceURL)
While $Ended_b = 0 ; wait for download.  Ended_b is set by the event function
    Sleep (250)
WEnd
SplashOff()
If $COMError = "no" Then ; save the result to file
    $FileHandle = FileOpen ($TempFile,18)
    FileWrite ($FileHandle, $oHTTP.ResponseBody)
    FileClose($FileHandle)
    ShellExecute ($TempFile) ; open the file for viewing
Else
    MsgBox (0,"ERROR!", "Winhttprequest download failed.")
EndIf
$oHTTP = 0
Exit

;FUNCTIONS
Func MyErrFunc() ; error handler for winhhtprequest com errors
    $HexNumber = Hex($oMyError.number, 8)
    if $ReportWinHTTPRequestErrors = "yes" Then
        SetError(1)
        $COMError = "yes" ; set error flag
    EndIf
EndFunc   ;==>MyErrFunc

Func WinHTTPEvent_ ($EventName) ; event handler function
    if $EventName = "OnResponseFinished" then $Ended_b = 1 ; set downloading flag
EndFunc

Share this post


Link to post
Share on other sites



You need to create a function named WinHTTPEvent__OnResponseFinished

From the AutoIT Helpfile in the 'COM Extensions to AutoIt' section : 'you can add a UDF with only the prefix. In this example: Func IEEvent_($Eventname). When an event is received and no IEEvent_ Eventname UDF exists, this function will be called instead and the name of the event will be placed in the variable $Eventname.'

This is what I based the function on. It it not correct?

Share this post


Link to post
Share on other sites

For the record, this forum is for AutoItX, not AutoIt with COM objects. Lots of people make that mistake.

Can you add some kind of debug statements between lines to see where it is failing? Like add a ConsoleWrite("Line #1" & @CRLF) between each line. It's possible that it's failing somewhere where you can check something.

Share this post


Link to post
Share on other sites

I thought I might have posted in the wrong place - can I move it, or should I repost in the general support forum?

As to dubug, I had HEAPS of debug line in the original code, but deleted them in what I posted, trying and make the posting the shortest possible code that showed the crash. It crashes while waiting in the While-Wend loop. The interval of time it waits matches the time taken for the download to complete, which is what makes me think it's crashing when the event is fired.

Share this post


Link to post
Share on other sites

Just leave it here for now, a moderator can move it later if needed.

Good to see you doing some leg work though. Most people are all "it doesn't work fix it fool". Which version of AutoIt are you using? The release or beta?

Share this post


Link to post
Share on other sites

Thanks Richard :-)

I'm using release version v3.3.0.0

Share this post


Link to post
Share on other sites

It may be worth trying the beta then. Even though it's called beta, it's almost always stable. See if the problem occurs in the beta for you as well.

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  
Followers 0