我使用的程序运行.VBS脚本
那么,在OnResponseFinished VBScript中,如何处理WinHttpRequest对象的事件呢?
Set oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
oHTTP.Open "GET", "http://www.google.com", True
oHTTP.Send发布于 2014-06-15 21:45:03
当winhttp响应出现时,我试图让一些代码执行(在HTA文件中使用VBScript )。您可以考虑将事件代码放在发送之后。使用以下代码,用户界面在等待响应时不会挂起:
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
objHTTP.Open "GET", "http://www.google.com", True
objHTTP.Send
objHTTP.WaitForResponse 'pauses execution, but does not hang UI
'from now on, execution only takes effect after completion of the response:
msgbox objHTTP.responseText 'an example of what can be done with the response这似乎与脚本文件的同步winhttp相同,这可能是您要寻找的。因此,在使用用户界面时,可能会注意到唯一的区别。
发布于 2011-02-26 20:05:43
将调用Open方法的第三个参数更改为false。然后在调用发送后将代码放在OnResponseFinished中。
发布于 2012-01-06 04:03:48
使用WScript的CreateObject,而不是内置的事件处理程序。
Set oHTTP = WScript.CreateObject(
"WinHttp.WinHttpRequest.5.1",
"oHTTP_"
)https://stackoverflow.com/questions/5124912
复制相似问题