Sign in to follow this  
Followers 0
RUVATA

ObjEvent of "winhttp.winhttprequest.5.1" COM-object

8 posts in this topic

I'am sorry for the bad english :huh2:

I have a problem with event handling of "winhttp.winhttprequest.5.1" COM-object

Dim $sServerURL = 'http://94.233.79.242:8000'
Dim $oHTTP = ObjCreate('winhttp.winhttprequest.5.1')
Dim $oEventEmitter = ObjEvent($oHTTP, 'Evt_', 'IWinHttpRequestEvents')
    $oHTTP.Open("POST", $sServerURL, True)
    $oHTTP.Send('test')
    $oHTTP.WaitForResponse()
MsgBox(0, $sServerURL & '--Response', $oHTTP.ResponseText())

Func Evt_OnResponseFinished()
    MsgBox(0,'Event Emitter', 'произошло событие OnResponseFinished')
EndFunc

Func Evt_OnError()
    MsgBox(0,'Event Emitter', 'произошло событие OnError')
EndFunc

this code causes a system error, but AutoIt interpriter have no problem

and stop executing with

AutoIT3.exe ended.rc:-1073741819

specification to using "winhttp.winhttprequest.5.1"

example of working code would be very helpful to me ...

Share this post


Link to post
Share on other sites



There is a (User Defined Functions) available. This UDF should do what you want or at least give you an idea how to do it yourself.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The WinHTTP.au3 UDF using "winhttp.dll"... resp. based on the WinHTTP C/C++ API Reference

but, my application based on the COM-object of winhttp.winhttprequest.5.1, this object also have same functionality

and reference...

From the Help Manual for AutoIt3:

ObjEvent ( $ObjectVar, "functionprefix" [, "interface name"] )

I have an object and know the name of the interface...

Why my code does not work?

I think I allow a logical error in my code ...

Edited by RUVATA

Share this post


Link to post
Share on other sites

From the Help Manual for AutoIt3:

ObjEvent ( $ObjectVar, "functionprefix" [, "interface name"] )

Note: It must be a supported as outgoing for theObject AND it must be of type DISPATCH

Is this true as well?

What error message do you get during run time?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The WinHTTP.au3 UDF using "winhttp.dll"... resp. based on the WinHTTP C/C++ API Reference

but, my application based on the COM-object of winhttp.winhttprequest.5.1, this object also have same functionality

and reference...

From the Help Manual for AutoIt3:

I have an object and know the name of the interface...

Why my code does not work?

This COM object is hosted by the same DLL an is build upon the same functions.

Regardless of that you won't be able to use IWinHttpRequestEvents, primarily because that sort of interfaces are not supported by automation (inherits from IUnknown). New beta AutoIt have ability to detect this kind of situations and report them to the user. Meaning if you use AutoIt beta, there won't be unexpected behaviors.

Another thing to consider is reentrant WinHTTP nature during the asynchronous completion callback. This means that even if IWinHttpRequestEvents could be used (future AutoIt versions) you would still have problems with the semantics of your code.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

OK,

Thanks, I suspected that the AutoIt does not support CallBack's fully

Edited by RUVATA

Share this post


Link to post
Share on other sites

The answer is in trancexx's reply: "... primarily because that sort of interfaces are not supported by automation ...".

Seems you're out of luck and can't do what you try to do :huh2:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Solution of the problem:

You can use 'Msxml2.XMLHTTP.6.0' instead of 'winhttp.winhttprequest.5.1'

it allows you to control your condition through a property readyState

1 person likes this

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