Memo/2005-02-16
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
#contents
*WSH 関連 [#u8fac02d]
**Internet Explorer の自動化 [#rdcae1ce]
***はてなブックマークの登録処理の自動化 [#u960ab11]
-はてなブックマークの登録処理の自動化
' AddBookmark.vbs
' Usage : CScript AddBookmark.vbs
' <処理概要>
' 1. お気に入りフォルダの取得
' 2. お気に入りの URL を取得
' 3. お気に入りの URL を Internet Explorer で表示
' 4. 表示された URL を「はてなブックマーク」に登録
' 5. Internet Explorer を閉じる
' 6. 2〜5 の繰り返し
'
Option Explicit
Main
Sub Main
Dim nResult
nResult = MsgBox( "はてなブックマークへの一括登録処...
If nResult <> vbOK Then
' OK 以外の場合、処理を抜けます。
Exit Sub
End If
' お気に入りのブックマークの一括登録処理
' ↓ 処理を有効にする場合、以下のコメントを外してくだ...
' AddBookmarkFromFavorites
' 指定した URL のリストの一括登録処理
' ↓ 処理を有効にする場合、以下のコメントを外してくだ...
' AddBookmarkFromList
' 処理の終了
MsgBox "はてなブックマークへの登録処理を完了しました...
End Sub
Sub AddBookmarkFromList
Dim dic
Set dic = CreateObject("Scripting.Dictionary")
' ↓登録したい URL をここに記述
dic.Add "http://www.hatena.ne.jp/1108104573", ""
dic.Add "http://www.hatena.ne.jp/1108213360", ""
dic.Add "http://www.hatena.ne.jp/1108215897", ""
dic.Add "http://www.hatena.ne.jp/1108438733", ""
' リストの内容をブックマークとして登録
AddBookmarks dic
End Sub
Sub AddBookmarkFromFavorites
Dim dic
Set dic = CreateObject("Scripting.Dictionary")
' お気に入りの情報を取得
RetrieveFavorites dic
' リストの内容をブックマークとして登録
AddBookmarks dic
End Sub
Function RetrieveFavorites( dic )
Dim shell
Set shell = CreateObject("Shell.Application")
Dim folder
Set folder = shell.NameSpace(6) ' お気に入りフォルダ
FavoritesToDictionary folder, dic
End Function
Function FavoritesToDictionary( folder, dic )
Dim wsh
Set wsh = CreateObject("WScript.Shell")
' サブディレクトリも対象とする
Dim item
For Each item In folder.Items
If item.IsFolder Then
FavoritesToDictionary item.GetFolder, dic
ElseIf item.IsLink Then
Dim link
Set link = wsh.CreateShortcut( item.Path )
' お気に入りの URL の登録情報を取得
dic.Add link.TargetPath, item.Name
End If
Next
End Function
Function AddBookmarks( dicURL )
Dim strURL
' データ件数分ループ
For Each strURL In dicURL
AddBookmark strURL
Next
End Function
Function AddBookmark( strURL )
Dim objIE
Set objIE = CreateObject("InternetExplorer.Applicati...
' IE の画面を表示させたくない場合は False をセットし...
objIE.Visible = True
' ページロード&タイトル取得
objIE.Navigate strURL ' ページの読み込み
While ( objIE.Busy ) : WScript.Sleep 100 : Wend
Dim strTitle
strTitle = objIE.Document.Title
' はてなブックマークの登録処理
Dim strCGI
' strCGI = "http://b.hatena.ne.jp/add?mode=confirm&ur...
strCGI = "http://b.hatena.ne.jp/add?mode=confirm&tit...
objIE.Navigate strCGI ' 登録画面の呼び出し
While ( objIE.Busy ) : WScript.Sleep 100 : Wend
objIE.Document.Forms(0).commit.Click ' 追加するボタ...
While ( objIE.Busy ) : WScript.Sleep 100 : Wend
objIE.Quit
Set objIE = Nothing
' 念のためウェイトを入れておく
WScript.Sleep 1000
End Function
--動作保証は致しかねます。実行は自己責任でお願いします。
-参考情報
--ShellFolder / Folderオブジェクト、FolderItemsコレクショ...
---http://www.roy.hi-ho.ne.jp/mutaguchi/wsh/object/shellf...
--ShellSpecialFolderConstants Enumerated Type
---http://msdn.microsoft.com/library/en-us/shellcc/platfo...
Const ssfFAVORITES = 6
--WshShellオブジェクトの詳細 / ショートカットの作成
---http://www.atmarkit.co.jp/fwin2k/operation/wsh06/wsh06...
--WshUrlShortcutオブジェクト
---http://www.roy.hi-ho.ne.jp/mutaguchi/wsh/object/urlsho...
--Internet Explorerオブジェクト (InternetExplorer.Applica...
---http://www.roy.hi-ho.ne.jp/mutaguchi/wsh/object/ie.htm
-はてな
--http://www.hatena.ne.jp/1108438733
--http://www.hatena.ne.jp/1108104573
終了行:
#contents
*WSH 関連 [#u8fac02d]
**Internet Explorer の自動化 [#rdcae1ce]
***はてなブックマークの登録処理の自動化 [#u960ab11]
-はてなブックマークの登録処理の自動化
' AddBookmark.vbs
' Usage : CScript AddBookmark.vbs
' <処理概要>
' 1. お気に入りフォルダの取得
' 2. お気に入りの URL を取得
' 3. お気に入りの URL を Internet Explorer で表示
' 4. 表示された URL を「はてなブックマーク」に登録
' 5. Internet Explorer を閉じる
' 6. 2〜5 の繰り返し
'
Option Explicit
Main
Sub Main
Dim nResult
nResult = MsgBox( "はてなブックマークへの一括登録処...
If nResult <> vbOK Then
' OK 以外の場合、処理を抜けます。
Exit Sub
End If
' お気に入りのブックマークの一括登録処理
' ↓ 処理を有効にする場合、以下のコメントを外してくだ...
' AddBookmarkFromFavorites
' 指定した URL のリストの一括登録処理
' ↓ 処理を有効にする場合、以下のコメントを外してくだ...
' AddBookmarkFromList
' 処理の終了
MsgBox "はてなブックマークへの登録処理を完了しました...
End Sub
Sub AddBookmarkFromList
Dim dic
Set dic = CreateObject("Scripting.Dictionary")
' ↓登録したい URL をここに記述
dic.Add "http://www.hatena.ne.jp/1108104573", ""
dic.Add "http://www.hatena.ne.jp/1108213360", ""
dic.Add "http://www.hatena.ne.jp/1108215897", ""
dic.Add "http://www.hatena.ne.jp/1108438733", ""
' リストの内容をブックマークとして登録
AddBookmarks dic
End Sub
Sub AddBookmarkFromFavorites
Dim dic
Set dic = CreateObject("Scripting.Dictionary")
' お気に入りの情報を取得
RetrieveFavorites dic
' リストの内容をブックマークとして登録
AddBookmarks dic
End Sub
Function RetrieveFavorites( dic )
Dim shell
Set shell = CreateObject("Shell.Application")
Dim folder
Set folder = shell.NameSpace(6) ' お気に入りフォルダ
FavoritesToDictionary folder, dic
End Function
Function FavoritesToDictionary( folder, dic )
Dim wsh
Set wsh = CreateObject("WScript.Shell")
' サブディレクトリも対象とする
Dim item
For Each item In folder.Items
If item.IsFolder Then
FavoritesToDictionary item.GetFolder, dic
ElseIf item.IsLink Then
Dim link
Set link = wsh.CreateShortcut( item.Path )
' お気に入りの URL の登録情報を取得
dic.Add link.TargetPath, item.Name
End If
Next
End Function
Function AddBookmarks( dicURL )
Dim strURL
' データ件数分ループ
For Each strURL In dicURL
AddBookmark strURL
Next
End Function
Function AddBookmark( strURL )
Dim objIE
Set objIE = CreateObject("InternetExplorer.Applicati...
' IE の画面を表示させたくない場合は False をセットし...
objIE.Visible = True
' ページロード&タイトル取得
objIE.Navigate strURL ' ページの読み込み
While ( objIE.Busy ) : WScript.Sleep 100 : Wend
Dim strTitle
strTitle = objIE.Document.Title
' はてなブックマークの登録処理
Dim strCGI
' strCGI = "http://b.hatena.ne.jp/add?mode=confirm&ur...
strCGI = "http://b.hatena.ne.jp/add?mode=confirm&tit...
objIE.Navigate strCGI ' 登録画面の呼び出し
While ( objIE.Busy ) : WScript.Sleep 100 : Wend
objIE.Document.Forms(0).commit.Click ' 追加するボタ...
While ( objIE.Busy ) : WScript.Sleep 100 : Wend
objIE.Quit
Set objIE = Nothing
' 念のためウェイトを入れておく
WScript.Sleep 1000
End Function
--動作保証は致しかねます。実行は自己責任でお願いします。
-参考情報
--ShellFolder / Folderオブジェクト、FolderItemsコレクショ...
---http://www.roy.hi-ho.ne.jp/mutaguchi/wsh/object/shellf...
--ShellSpecialFolderConstants Enumerated Type
---http://msdn.microsoft.com/library/en-us/shellcc/platfo...
Const ssfFAVORITES = 6
--WshShellオブジェクトの詳細 / ショートカットの作成
---http://www.atmarkit.co.jp/fwin2k/operation/wsh06/wsh06...
--WshUrlShortcutオブジェクト
---http://www.roy.hi-ho.ne.jp/mutaguchi/wsh/object/urlsho...
--Internet Explorerオブジェクト (InternetExplorer.Applica...
---http://www.roy.hi-ho.ne.jp/mutaguchi/wsh/object/ie.htm
-はてな
--http://www.hatena.ne.jp/1108438733
--http://www.hatena.ne.jp/1108104573
ページ名: