Search the Community
Showing results for tags 'mht'.
-
Today I found this: https://github.com/gildas-lormeau/SingleFile/discussions/1226 I tried to use this with GoogleChrome https://chrome.google.com/webstore/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle I found some solution here: https://stackoverflow.com/a/75376708/5314940 And I'm trying to do it this way: function send(extensionId, msg, callback, retry = 20) { const timer = setTimeout(send, 100, extensionId, msg, callback, retry - 1); chrome.runtime.sendMessage(extensionId, msg, response => { if (!chrome.runtime.lastError || !retry) { clearTimeout(timer); callback(response); } }); }; send('{531906d3-e22f-4a6c-a102-8057b88a1a63}', '{ action: "save-page" }'); But errors occurs. Any help with how to use it with JS ? EIDT: After finding a way I provide example in AutoIt
-
I'm trying to save opened page in one MHT page. I found many solutions like this: _INetGetMHT( "http://www.yahoo.com", "C:\test.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 but can't find any which show how to save WebPage using AutoIt opened by _IE.. Functions. but I come to this page: http://microsoft.public.scripting.vbscript.narkive.com/WqvoHF8S/retrieve-html-from-a-website-using-vbscript#post3 <!-- FileName : SaveMhtmEn.hta --> <html><head><script language=vbs> Dim EvtSrc, WS, FS, URL, Path, Title, EN Set WS = CreateObject("WScript.Shell") Set FS = CreateObject("Scripting.FileSystemObject") On Error Resume Next Set EvtSrc=external.menuarguments.event.srcelement EN = Err.Number On Error GoTo 0 If EN <> 0 Then Reg_UnReg ' Sub SaveAsMhtml() URL = EvtSrc.Href If IsNull(URL) Or LCase(Left(URL, 7)) <> "http://" Then _ ShowMessage 1 Path = "%userprofile%\My Documents\HomePages\" Path = WS.ExpandEnvironmentStrings(Path) If Not FS.FolderExists(Path) Then FS.CreateFolder Path external.menuarguments.status = "Now downloading..." With CreateObject("InternetExplorer.Application") .Navigate URL Do While .Busy: Loop Title = .Document.Title:If Title = "" Then Title = ":" With CreateObject("CDO.Message") On Error Resume Next .CreateMHTMLBody(URL) If Err Then On Error GoTo 0: ShowMessage 2 FS.CreateTextFile Path & Title & ".mht" If Err Then _ Title = Replace(Date, "/", "_") & "_" & Replace(Time, ":", "_") On Error GoTo 0 .BodyPart.GetStream.SaveToFile Path & Title & ".mht", 2 End With .Quit End With external.menuarguments.status = "" ShowMessage 3 End Sub ' Sub ShowMessage(Mes) Select Case Mes Case 1: WS.PopUp "No link address.", 2 Case 2: WS.PopUp "Downloading failed", 2 Case 3: WS.PopUp "Downloading finished.", 2 End Select window.close End Sub ' Sub Reg_UnReg() Const RootKey = "HKCU\Software\Microsoft\Internet Explorer\MenuExt\" Const Name = "SaveAs &Mht Format" Dim Path, TKey, Dummy, EN Path = document.urlunencoded TKey = RootKey & Name & "\" On Error Resume Next Dummy = WS.RegRead(TKey): EN = Err.Number On Error GoTo 0 If EN = 0 Then WS.RegDelete TKey WS.PopUp "Deleted from context menu", 2 Else WS.RegWrite TKey, Path, "REG_SZ" WS.RegWrite TKey & "contexts", &H20, "REG_DWORD" WS.PopUp "Added to context menu", 2 End If window.close End Sub </script></head><body onload=SaveAsMhtml></body></html> Question: How to use this code in page opened by AutoIt _IE... functions ? Best regards, mLipok