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
http://wakabamac.blog95.fc2.com/blog-entry-518.html

Quicksilver : ランチャ+システムの一部のような総合ユーティリティ
前の記事『Help Search』のように、Quicksilver では AppleScript を使って独自のActionを作ることができます。
テキストを扱うActionの AppleScript のひな形が
『quicksilver:creations:applescript_get_text_from_quicksilver [docs]』
に公開されています。
▽ ScriptEditor で開く
using terms from application "Quicksilver"
on process text theString
--insert commands here:
display dialog theString
end process text
end using terms from
これの「
--insert commands here:
」のところにコマンドを入れれば、テキストを扱うActionが作れます。

これをスクリプトエディタで「○○○.scpt」とか適当なファイル名で次の場所に保存します。
~/Library/Application Support/Quicksilver/Actions
(※「Actions」フォルダがない場合は作る)
これで Quicksilver を再起動すると、このスクリプトをActionとして使えるようになります。
【 辞書.appで単語を調べる Action 】
『how to use Dictionary Plugin - Blacktree: Quicksilver | Google グループ』
に掲載されていたもの、そのままのAppleScriptです。
これは Quicksilver で入力したテキストを 辞書.app で調べる為のものです。
▽ ScriptEditor で開く
using terms from application "Quicksilver"
on process text lookup
tell application "Dictionary" to activate
tell application "System Events" to tell process "Dictionary"
keystroke "f" using {command down, option down}
keystroke "a" using command down
keystroke lookup
keystroke return
end tell
end process text
end using terms from
※このスクリプトは システム環境設定の「ユニバーサルアクセス」パネルで
「補助装置にアクセスできるようにする」にチェックを入れないと機能しません。

これをスクリプトエディタで「LookUp Word.scpt」とか適当なファイル名で次の場所に保存します。
~/Library/Application Support/Quicksilver/Actions
(※「Actions」フォルダがない場合は作る)
これで Quicksilver を再起動すると このスクリプトをActionとして使えるようになります。
1stPaneにテキストモードで文字を入力して、2ndPaneで先程の「LookUp Word」のActionを選択して実行します。

スクリプトファイルにカスタムアイコンを貼付けると、それなりに見えます。
Services Menu Module で「Look Up in Dictionary」Actionと同じですが、サービスメニューを介さない分、こちらの方が早いです。
また、「Process Text...」Actionを使えば、Action用に作ったAppleAcriptを Object として扱うことができます。


これを左のようにTrigger登録すると、辞書で調べものをするときに便利です。
・Object「LookUp Word.scpt」
・Action「Process Text...」
・Arugument「ブランク」
※command+X でカットして「ブランク」にできる
この使い方をするときはスクリプトの
「
keystroke return
」を無効にするか「delay
」で調整した方がいいかも。
ただ、このスクリプトは単語を「
keystroke
」で入力しているので、日本語が使えません。要するに英和辞典のみ。
だから、クリップボードを介して日本語も使えるようにしてみました。
▽ ScriptEditor で開く
using terms from application "Quicksilver"
on process text lookup
set the clipboard to lookup
tell application "Dictionary" to activate
tell application "System Events" to tell process "Dictionary"
keystroke "f" using {command down, option down}
keystroke "a" using command down
keystroke "v" using command down
--keystroke return
end tell
end process text
end using terms from
これも環境によっては「
delay
」などで調整した方がいいかも。
【 Quicksilverで入力したテキストをGrowlで表示させる Action 】
自分でも一つActionを作ってみました。
Quicksilver のテキストモードで入力したものを Growl で表示させるものです。
▽ ScriptEditor で開く
(* Send to Growl *)
using terms from application "Quicksilver"
on process text Growl_description_QS
tell application "GrowlHelperApp"
-- 一度このスクリプトを実行して Growlに登録された後に
-- この下の行2カ所の頭の「--」を削除して保存し直して下さい
-- (* この行の頭を削除
set the allNotificationsList to {"Message from Quicksilver"}
set the enabledNotificationsList to {"Message from Quicksilver"}
register as application ??
"Send to Growl from QS" all notifications allNotificationsList ??
default notifications enabledNotificationsList ??
icon of application "Quicksilver"
-- この行の頭のを削除 *)
-- Send a Notification...
notify with name ??
"Message from Quicksilver" title ??
"Message from Quicksilver" description ??
Growl_description_QS application name "Send to Growl from QS"
end tell
end process text
end using terms from
※一度このスクリプトを実行してGrowlに「Send to Grwol from QS」というものが登録されれば、スクリプト中のGrowl登録部分は必要なくなります。
別にあっても構わないのですが、気になる人は上記の「--」2カ所を削除して、コマンドをコメントに変換するといいでしょう。
これを「Send to Grwol.scpt」とか適当な名前で保存して Quicksilver で実行してみるとこんな感じです。

1stPaneで入力したテキストがGrowlで表示されます。

使い道としては、「Run at Time...」Actionなどでリマインダとして使用するときに、これを使ってGrowl表示させると吉です。
これを一度実行すると、Growlの環境設定パネルの「アプリケーション」タブに
「Send to Grwol from QS」というものが追加されます。
ここでGrowlの表示設定を行います。
【 リンクの無いURLを開く Action 】
『●アップルスクリプト その1 (web関連)』
の「自動リンクになってないURLやttp://、wwwなどで始まってるURLを選択して開くスクリプト」を参考にしました。
(参考にしたと言うより、主要な部分をコピペしただけです。)
▽ ScriptEditor で開く
(* Open Unlinked URL *)
using terms from application "Quicksilver"
on process text surl
if surl contains return then set surl to do shell script "echo " & quoted form of surl & " | sed s/" & return & "//g"
if surl contains " " then set surl to do shell script "echo " & quoted form of surl & " | sed s/" & quoted form of " " & "//g"
if surl contains "://" then
set AppleScript's text item delimiters to "://"
set surl to "http://" & text item 2 of surl
else
set surl to "http://" & surl
end if
tell application "System Events" to open location surl
end process text
end using terms from
これを「Open Unlinkded URL.scpt」とかの適当な名前で
~/Library/Application Support/Quicksilver/Actions
に保存します。
使い方は、例えば 下のような「h」が抜けてるURLがあったとします。
ttp://www.apple.com/jp/
これを選択して、⌘ command + ⎋ esc などで Quicksilver に表示させます。

これで2ndPaneで先程保存した「Open Unlinkded URL」をActionに選択して実行すれば、Webブラウザでそのページを開くことができます。
ちなみにハイパーリンクになっていない完全なURLアドレスの場合
http://www.apple.com/jp/
これだと ⌘ command + ⎋ esc などで Quicksilver に表示させて、
普通の「Open URL」Actionで、そのページを開くことができます。
【 その他のAppleScriptで作られた Action 】
いろんなところで Quicksilver のActionとして使える AppleScript が公開されています。
▶ Bwana で manページ を開く Action
Thing collar Bu logさん の『Bwana + Quicksilver』より。

UNIXの「man」ページをSafariで表示する「Bwana」を Quicksilver で操作できるようにする AppleScript です。
これを上記のリンク先ページで、スクリプトエディタにコピペして
「Show_Bwana.scpt」とか適当な名前で保存します。
これを使えば、Quicksilver でUNIXのコマンドを検索できます。

▶ EasyFind で検索する Action

ファイル検索ユーティリティ「EasyFind」を使って、Quicksilver の1stPaneに入力したテキストを検索語句としてファイル検索できます。
スクリプトのソースは
『Quick search with Quicksilver and EasyFind』
ここでコピペして「Search(EasyFind).scpt」とかの適当な名前で保存します。

これを実行すると、1stPaneに入力したテキストで EasyFind で検索します。
検索する場所(フォルダ)は、それ以前に設定していた場所になります。
スクリプトのコメント行を編集すれば、検索対象を「ファイルとフォルダ」「ファイルのみ」「フォルダのみ」「ファイルコンテンツ」のどれか選択できます。
この記事では Quicksilver B55 を使用しています。
(関連記事)
Quicksilver/ AppleScript で Action を作る(1)
Quicksilver/ AppleScript で Action を作る(2)
Quicksilver/ AppleScript で Action を作る(3)
Quicksilver --- 基本的な概略説明
Quicksilver/ 基本的な使用例
Quicksilver/ Catalogの設定
Quicksilver/ Actionについて(1)
Quicksilver/ Actionについて(2)
Quicksilver/ Actionについて(3)
Quicksilver/ Actionについて(4)- Command Objects
Quicksilver/ Triggers の説明(1)
Quicksilver/ Triggers の説明(2)
Quicksilver/ Plug-ins について
Quicksilver/ Proxy Objects について
Quicksilver/ Triggers の説明(3)- Mouse Triggers
Quicksilver/ Triggers の説明(4)- Abracadabra Triggers
Quicksilver/ ショートカットまとめ
すべてのQuicksilver記事のリンクは『Quicksilver』の(関連記事)にあります。
▽同じ「タグ」が付いた関連記事
trackback URL