Vista IEで、「Web ページ、HTML のみ (*.htm;*.html)」で「名前を付けて保存」する。
IEで「Web ページ、HTML のみ (*.htm;*.html)」で保存しようとしても、デフォルトが、IE7/IE8は「Web アーカイブ、単一のファイル (*.mht)」、IE6は「Web ページ、完全 (*.htm;*.html)」なので、これをいちいち変更しなければなりません。面倒臭。
IE7でShell.Windows().Item()が使えなくなったので、コンテキストメニュー拡張に変更しましたが、Vistaで「保護モード:有効」のページからのコンテキストメニュー拡張でActiveXObjectが使えなくなったため、再度、WSH起動に変更します。
IEの「お気に入りセンタ」か「お気に入りバー」から起動します。
Web ページ、HTML のみ.vbs
Set ies=CreateObject("Shell.Application").Windows()
For Each ie In ies
If ie.ReadyState=4 Then If TypeName(ie.Document)="HTMLDocument" Then If ie.Document.hasFocus() Then Exit For
Next
If IsEmpty(ie) Then
For Each ie In ies
If ie.ReadyState<>4 Then
ElseIf TypeName(ie.Document)="HTMLDocument" Then
ie.Document.focus
If ie.Document.hasFocus() Then Exit For
End If
Next
End If
If IsEmpty(ie) Then
MsgBox "Not Found"
WScript.Quit
End If
Set fso=CreateObject("Scripting.FileSystemObject")
title=ie.Document.title
If title="" Then
title=fso.GetFileName(ie.Document.location.pathname)
End If
Select Case fso.GetExtensionName(title)
Case "htm","html"
Case Else
title=title & ".htm"
End Select
title=Replace(title,"/","-")
title=Replace(title,":","")
title=Replace(title,"\","")
title=Replace(title,"*","")
title=Replace(title,"?","")
title=Replace(title,"<","")
title=Replace(title,">","")
title=Replace(title,"|","")
title=Replace(title,"""","")
title=Replace(fso.GetBaseName(title),".","_") & "." & fso.GetExtensionName(title)
ie.Document.execCommand "saveas",True,title
※ スクリプトファイル(またはそのショートカット)は他で作って、「お気に入り」か「お気に入りバー」に「移動」で入れること。
※ ウィンドウのフォアグラウンドロックを利用しているので、フォアグラウンドロックを無効(タイムアウト値を0)にしていると使えません。
« Vista IEで、「Web ページ、完全 (*.htm;*.html)」で「名前を付けて保存」する。 | トップページ | IE7/IE8で、現在または最後にアクティブなIEを捕捉する。(その2) »