2022年5月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
無料ブログはココログ

« 2012年7月 | トップページ | 2012年9月 »

2012年8月29日 (水)

保存したサポート記事のファイル名に文書番号をに付ける。

htmlファイルをドロップします。

KB.vbs ファイル

Set ie=CreateObject("InternetExplorer.Application")
ie.Visible=True
ie.Navigate WScript.Arguments.Item(0)
Do While ie.Busy Or ie.ReadyState<>4
  WScript.Sleep 100
Loop
For Each elem In ie.Document.getElementsByTagName("META")
  NameStr = elem.getAttribute("name")
  If Len(NameStr) Then
    If LCase(NameStr) = "ms.sup_cid"  Then
      KB="KB" & elem.getAttribute("content") & " "
      Exit For
    End If
  End If
Next
ie.Quit
If Not IsEmpty(KB) Then
  Set fso=CreateObject("Scripting.FileSystemObject")
  fso.GetFile(WScript.Arguments.Item(0)).Name=KB & fso.GetFileName(WScript.Arguments.Item(0))
End If

2012年8月28日 (火)

サポート記事を保存するとき、文書番号をファイル名に付ける。

ブックマークレットでタイトルに文書番号を付けます。

javascript:document.title='KB'+location.pathname.split('/')[2]+' '+document.title;void(0)

2012年8月25日 (土)

セキュリティレベルに依存して実行できないBookmarkletを実行する。(その2)

※ 旧記事はIE6までなので、IE9用。

javascript:やvbscript:プロトコルは、表示中のWebページのセキュリティゾーンのセキュリティレベルに依存するため、一般に実行できません。

ブックマークレットのインターネットショートカットを実行するには、次のVBSファイルをお気に入りかお気に入りバーに入れて、インターネットショートカットをドロップします。

execBookmarklet.vbs

Set wShell=CreateObject("WScript.Shell")
wShell.SendKeys "^{f6}"
For Each ie In CreateObject("Shell.Application").Windows()
  If ie.ReadyState=4 Then If TypeName(ie.Document)="HTMLDocument" Then If ie.Document.hasFocus() Then Exit For
Next
If IsEmpty(ie) Then
  MsgBox "Current IE not found."
  WScript.Quit
End If
ie.Document.parentWindow.setTimeout CreateObject("WScript.Shell").CreateShortCut(WScript.Arguments(0)).TargetPath

また、アドレスバーにjavascript:やvbscript:プロトコルを直接入力する代わりに、次のVBSファイルをお気に入りかお気に入りバーに入れて、こちらのInputBoxに入力します。

execScript.vbs

Set wShell=CreateObject("WScript.Shell")
wShell.SendKeys "^{f6}"
For Each ie In CreateObject("Shell.Application").Windows()
  If ie.ReadyState=4 Then If TypeName(ie.Document)="HTMLDocument" Then If ie.Document.hasFocus() Then Exit For
Next
If IsEmpty(ie) Then
  MsgBox "Current IE not found."
  WScript.Quit
End If
Do
  script=InputBox("Enter script...",WScript.ScriptName,script,,0)
  If script="" Then Exit Do
  ie.Document.parentWindow.setTimeout script
Loop

ここで、window.execScript()でなく、window.setTimeout()を使用するところが味噌です。前者は表示中のWebページのセキュリティゾーンのセキュリティレベルに依存します。後者は依存しません。

2012年8月14日 (火)

htmlファイルにbaseタグを追加する。(その2)

htmlファイルをドロップすると、baseタグとMOTWを追加します。urlはieのアクティブタブから取ってきます。

base.vbs htmlファイル

function fold40(byval s)
do while len(s)
fold40=fold40 & left(s,40) & " "
s=mid(s,41)
loop
end function
Set Shell=CreateObject("Shell.Application")
Randomize
For Each ie In Shell.Windows
  If LCase(Right(ie.FullName,13))="\iexplore.exe" Then
    r=CStr(Rnd)
    ie.StatusText=r
    If ie.StatusText=r Then
      url=ie.LocationURL
      url=InputBox(ie.LocationName & vbLf & fold40(url),"Is this URL OK ?. Or Enter URL",url)
      If url<>"" Then
        ie.StatusText=""
        Exit For
      End If
    End If
    ie.StatusText=""
  End If
Next
If url="" Then url=InputBox("Default URL","Is this URL OK ?. Or Enter URL","http://www.microsoft.com")
If url="" then wscript.quit
set dst=createobject("adodb.stream")
dst.open
dst.type=2
dst.charset="iso-8859-1"
dst.writetext "<!-- saved from url=(" & mid(10000+Len(Url),2)& ")" & Url & " -->",1
dst.writetext "<HTML><HEAD><BASE HREF=""" & Url & """></HEAD></HTML>",1
dst.position=0
dst.type=1
dst.position=dst.size
set src=createobject("adodb.stream")
src.open
src.type=1
src.loadfromfile wscript.arguments.item(0)
src.copyto dst
dst.savetofile wscript.arguments.item(0),2

2012年8月13日 (月)

htmlファイルにbaseタグを追加する。

htmlファイルをドロップすると、baseタグとMOTWを追加します。urlは固定。

base.cmd htmlファイル

copy "%~f1" "%~f1.tmp"
echo ^<base href=http://www.mirosoft.com /^>^<!-- saved from url=(0014)about:internet --^>>"%~f1"
copy "%~f1" + "%~f1.tmp" "%~f1"
del "%~f1.tmp"

« 2012年7月 | トップページ | 2012年9月 »