2011-01-26T10:40:25+09:00

LaunchBar でアドレス検索

LaunchBar をもっぱら愛用している。ほとんど不満はないけど、日本語を入力しての検索ができないのでAddress Book の検索には Spotlight メニューを使わざる得ないのがちょっと不満。そこで、LaunchBar からアドレス検索を実行する AppleScript を作ってみた。LaunchBar の action として動作する。

使い方は、Scripts メニューなどに置いて、LaunchBar に action として認識させる。そして、LaunchBar で選択してスペースキーを押すと、テキストを入力できるようになる。探したい人の名前などを入れて実行すれば、Spotlight ウインドウでアドレスを検索できる。

property _keyword : ""

on run
try
|main|()
on error msg number errno
if errno is not -128 then
activate
display alert msg message "Error Number : " & errno
end if
end try
end run

on perform_search(a_word)
tell application "LaunchBar"
perform service "Spotlight" with string "kind:contact " & a_word
end tell
end perform_search

on |main|()
tell application (path to frontmost application as Unicode text)
activate
set a_result to display dialog "Enter search word :" default answer my _keyword
end tell
set my _keyword to text returned of a_result
perform_search(my _keyword)
end |main|

on handle_string(a_text)
try
perform_search(a_text)
set my _keyword to a_text
on error msg number errno
if errno is not -128 then
activate
display alert msg message "Error Number : " & errno
end if
end try
end handle_string