CatchFish Posted October 8, 2005 Share Posted October 8, 2005 I create an instance of WinHttpRequest:$oWinHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")Then there are 3 things that AutoIt3 can't do:1. onreadystatechange...I want to set the onreadystatechange property which must be assigned the handle of a custom function. The problem is, there is no way to get a handle of a function, nor any special syntax support in AutoIt3. Therefore it is impossible to set a proper value for it. But in Javascript or VBScript I can do it in this way: oWinHttp.onreadystatechange = somefunction; //Javascript way oWinHttp.onreadystatechange = GetRef("SomeFunction") 'VBScript way2. Write to option()option() is a read/write property. I need to set the URL codepage to 936 (meaning gb2312), so I do this:Dim $WinHttpRequestOption_URLCodePage = 2 ;Code page $oWinHttp.open("GET", "http://www.google.com", false) $oWinHttp.option($WinHttpRequestOption_URLCodePage) = "936" $oWinHttp.send()Then I use ConsoleWrite() to view the value of $oWinHttp.option($WinHttpRequestOption_URLCodePage). The result is 65001 (meaning utf-8), same as the original, because AutoIt3 doesn't seem to support Object.Property(Item) = Value syntax which is widely used in Javascript and VBScript.3. responseBody...When $oWinHttp.send() successfully returns, $oWinHttp.responseBody should be an array of unsigned interger which contains raw data of the source. I need the raw data instead of $oWinHttp.responseText because I need to do some codepage transformation. I try to use the following code:Dim $oStream, $Result $oStream = ObjCreate("ADODB.Stream") $oStream.Type = 1 $oStream.Mode = 3 $oStream.Open $oStream.Write($oWinHttp.responseBody) $oStream.Position = 0 $oStream.Type = 2 $oStream.Charset = "gb2312" $Result = $oStream.ReadText()But the $Result is empty. I find that AutoIt3 doesn't support arrays like ResponseBody. Compared to the similar code in VBScript, everything works fine.Any ideas? Link to comment Share on other sites More sharing options...
Gordon J. Tyler Posted March 26, 2007 Share Posted March 26, 2007 Has anyone resolved the ResponseBody issue? -OR- A fix for InetGet() so that it works under Vista? Link to comment Share on other sites More sharing options...
AzKay Posted September 15, 2007 Share Posted September 15, 2007 Needing help on this too. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
DaleHohm Posted September 15, 2007 Share Posted September 15, 2007 (edited) Edits inline *:1) you certainly CAN do this with ObjEvent()2) there was a discussion about this involving the dictionary object a while back and it was resolved - can't find the thread at the moment. In any case, are you sure you want to pass a string into that option?* Looking at the code page values here http://msdn2.microsoft.com/en-us/library/ms776446.aspx would you want to pass 0x936 ?** Update2: looks like the codepage value is base10 rather than Hex, so use 936 (instead of "936" or 0x936)Examine the option and you will see that you are in fact affecting a change:$oWinHttp.open("GET", "http://www.google.com", false) ConsoleWrite($oWinHttp.option($WinHttpRequestOption_URLCodePage) & @CR) $oWinHttp.option($WinHttpRequestOption_URLCodePage) = 936 ConsoleWrite($oWinHttp.option($WinHttpRequestOption_URLCodePage) & @CR)3) if I remember correctly, this returns a "safeArray"... I have not found a way of dealing with this in AutoIt either - the IE .Navigate2 method uses this as well as many others* Looking at the msdn docs, it just says of responseBody "This property returns the response data in an array of unsigned bytes. If the response does not have a response body, an empty variant is returned."I looked into this out of curiosity a long time ago and quit when I got this far and saw that the response was empty.I would suggest that you create a working VBScript example with your best shot at AutoIt conversion... post it back here for discussion and then it may result in a feature request or bug report.Dale Edited September 15, 2007 by DaleHohm Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
DaleHohm Posted September 15, 2007 Share Posted September 15, 2007 Previous reply updated... Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
ShawnSharon Posted May 19, 2012 Share Posted May 19, 2012 Edits inline *: 1) you certainly CAN do this with ObjEvent() 2) there was a discussion about this involving the dictionary object a while back and it was resolved - can't find the thread at the moment. In any case, are you sure you want to pass a string into that option? * Looking at the code page values here http://msdn2.microsoft.com/en-us/library/ms776446.aspx would you want to pass 0x936 ? ** Update2: looks like the codepage value is base10 rather than Hex, so use 936 (instead of "936" or 0x936) Examine the option and you will see that you are in fact affecting a change: $oWinHttp.open("GET", "http://www.google.com", false) ConsoleWrite($oWinHttp.option($WinHttpRequestOption_URLCodePage) & @CR) $oWinHttp.option($WinHttpRequestOption_URLCodePage) = 936 ConsoleWrite($oWinHttp.option($WinHttpRequestOption_URLCodePage) & @CR) 3) if I remember correctly, this returns a "safeArray"... I have not found a way of dealing with this in AutoIt either - the IE .Navigate2 method uses this as well as many others * Looking at the msdn docs, it just says of responseBody "This property returns the response data in an array of unsigned bytes. If the response does not have a response body, an empty variant is returned." I looked into this out of curiosity a long time ago and quit when I got this far and saw that the response was empty. I would suggest that you create a working VBScript example with your best shot at AutoIt conversion... post it back here for discussion and then it may result in a feature request or bug report. Dale Thanks for the post and answers. ADODB.Stream method works for me. ( Windows 7 64bit ) But I prefer the BinarytoString Method. ; change flag if ResponseBody use other encoding $sHtml = BinaryToString($oHTTP.ResponseBody, 1) BTW: I found winhttp is always faster than inetread(autoit 3.3.8), any idea? Link to comment Share on other sites More sharing options...
water Posted May 19, 2012 Share Posted May 19, 2012 You shouldn't necro a thread 4.5 years old. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now