Jump to content

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


Recommended Posts

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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:

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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