newatthis Posted June 17, 2013 Share Posted June 17, 2013 Hello, I got AutoIt to call up a web page and used Send("{ALT}") Send("f") Send("a") to call up the "Save Webpage" dialog box, but for the life of me I can't access the box. In addition to the direct approach, I tried these lines: WinActivate("Save Webpage", "") Send("Testfile") Send("{ENTER}") and: WinActivate("[CLASS:Save Webpage]", "") Send("Testfile") Send("{ENTER}") Neither of them worked to save "Testfile.htm" [the test name for the Webpage I'm trying to save] from the open dialog box. How do I script it so that AutoIt saves the Webpage? Are there some commands that can access the dialog box, or should I use a different approach entirely? As the lines above indicate, I just want to save the webpage raw - nothing fancy Thanks. Link to comment Share on other sites More sharing options...
Danp2 Posted June 18, 2013 Share Posted June 18, 2013 Take a look at the IE.au3 function library and the function _IEDocReadHTML. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DW1 Posted June 18, 2013 Share Posted June 18, 2013 As pointed out by DanP2, you can easily read the HTML and save the results to a file with the IE functions. You can also do this with _INetGetSource. If you need the entire page (pictures, etc) you may want to look in to saving as mht. Here is an example of saving a page in mht format: ;EXAMPLE: _INetGetMHT( "http://msdn.microsoft.com/en-us/library/ms526453%28v=exchg.10%29.aspx", "D:\IMessage Interface.MHT" ) Func _INetGetMHT( $url, $file ) Local $msg = ObjCreate("CDO.Message") If @error Then Return False Local $ado = ObjCreate("ADODB.Stream") If @error Then Return False With $ado .Type = 2 .Charset = "US-ASCII" .Open EndWith $msg.CreateMHTMLBody($url, 0) $msg.DataSource.SaveToObject($ado, "_Stream") FileDelete($file) $ado.SaveToFile($file, 1) $msg = "" $ado = "" Return True EndFunc AutoIt3 Online Help Link to comment Share on other sites More sharing options...
newatthis Posted June 18, 2013 Author Share Posted June 18, 2013 Thanks to you both. I did look at _IEDocReadHTML, but couldn't find a way to save the contents of the variable to a file. My attempts to read it into a Notepad file were, to put it one way, comical. I should have explained: I'm trying to save the page after using AutoIt to fill in some fields and waiting for the server to return the data asked for. If I use the raw URL, that data won't be there: I need to fill in the forms first. That part, I already figured out. I asked because I couldn't find any IE_... function with "Save" in the title. Can you point out some way to get the _IEDocReadHTML variable into a saveable file without any fireworks? If so, thanks a lot. As pointed out by DanP2, you can easily read the HTML and save the results to a file with the IE functions. You can also do this with _INetGetSource. If you need the entire page (pictures, etc) you may want to look in to saving as mht. Here is an example of saving a page in mht format: ;EXAMPLE: _INetGetMHT( "http://msdn.microsoft.com/en-us/library/ms526453%28v=exchg.10%29.aspx", "D:\IMessage Interface.MHT" ) Func _INetGetMHT( $url, $file ) Local $msg = ObjCreate("CDO.Message") If @error Then Return False Local $ado = ObjCreate("ADODB.Stream") If @error Then Return False With $ado .Type = 2 .Charset = "US-ASCII" .Open EndWith $msg.CreateMHTMLBody($url, 0) $msg.DataSource.SaveToObject($ado, "_Stream") FileDelete($file) $ado.SaveToFile($file, 1) $msg = "" $ado = "" Return True EndFunc Link to comment Share on other sites More sharing options...
Solution DW1 Posted June 18, 2013 Solution Share Posted June 18, 2013 Sure, here is an example of saving a page after searching for something in google #include <IE.au3> Local $oIE = _IECreate("http://www.google.com", 0, 0) Local $oForm = _IEFormGetCollection($oIE, 0) Local $oQuery = _IEFormElementGetObjByName($oForm, "q") _IEFormElementSetValue($oQuery, "AutoIt IE.au3") _IEFormSubmit($oForm) While _IEPropertyGet($oIE, "busy") Sleep(100) WEnd FileWrite(@MyDocumentsDir & '\Results.html', _IEDocReadHTML($oIE)) _IEQuit($oIE) ShellExecute(@MyDocumentsDir & '\Results.html') Hope this helps Xandy 1 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
newatthis Posted June 20, 2013 Author Share Posted June 20, 2013 Thanks, again. You've given me enough to go on. FileOpen/FileWrite/FileClose did the trick. 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