
Quicksilver : ランチャ+システムの一部のような総合ユーティリティ
OS10.4以上(UB)、OS10.3.9 各対応
ドネーションウェア
Quicksilver は
AppleScriptをスクリプトメニューからでなくとも実行でき、
Triggerを使えば、それをホットキー・ホットコーナー・マウスジェスチャなどから実行することができます。
「
Mouse Trigger」「
Abracadabra Triggers」の記事でも、簡単なAppleScriptを使いましたが、それ以外にも Quicksilver で使ったら便利そうなものを採り上げてみたいと思います。
AppleScript初心者なので、おかしな点があるかもしれません。

下記のスクリプトは、スクリプトエディタを開いてコピペして、適当なファイル名で保存して下さい。
/Users/登録アカウント名/Library/Scripts/
の場所あたりに保存しておくといいと思います。
一部「\」を「\(バックスラッシュ)」の半角に直す必要があります。
【 現在日時・時刻を表示する AppleScript 】
『
quicksilver:creations:scripts [docs]』に現在日時と時刻を表示させるAppleScriptが紹介されていたので、ちょっと弄ってみました。
(現在日時・時刻を表示する)--Date set the_date to the current date
set the_year to (year of the_date) as text set the_month to (month of the_date) as integer as text set the_day to (day of the_date) as text set the_weekday to text from character 1 to character 3 of ((weekday of the_date) as text) if length of the_month is 1 then set the_month to "0" & the_month if length of the_day is 1 then set the_day to "0" & the_day
set the date_string to the_year & "/" & the_month & "/" & the_day & " (" & the_weekday & ")"
--Time set the_time to time of the (current date)
set the_hours to (the_time div hours) as text set the_minutes to ((the_time mod hours) div minutes) as text set the_seconds to (the_time mod minutes) as text if length of the_minutes is 1 then set the_minutes to "0" & the_minutes if length of the_seconds is 1 then set the_seconds to "0" & the_seconds
set time_string to the_hours & ":" & the_minutes & ":" & the_seconds
--Show LargeType set now_string to date_string & " - " & time_string tell application "Quicksilver" to show large type now_string as text (* --おまけ say ((weekday of the_date) as string) say the_day say (month of the_date) as string delay 0.3 say the_hours & the_minutes *)
|
これを実行すると、Quicksilver の「
Large Type」で現在日時・時刻を表示します。

【 Spacesを移動する AppleScript 】
AppleScriptもさっぱりわからないなりに、下のようなスクリプトを作ってみました。
(次のSpaceへ移動)(* Go Next Space *)
tell application "System Events" -- Spaces の総数を調べる tell expose preferences tell spaces preferences set sp_row to spaces rows set sp_clm to spaces columns set sp_all to sp_row * sp_clm end tell end tell -- 現在の Space Number を調べる tell process "SystemUIServer" tell menu bar 1 set mb to count (every menu bar item) repeat with i from 1 to mb tell menu bar item i if size = {34, 22} then try set sp_no_x to value as number if sp_no_x < 17 then set sp_no to sp_no_x end try end if end tell set i to i + 1 end repeat end tell end tell -- 次の Space へ移動 if sp_no < sp_all then set sp_no to sp_no + 1 else set sp_no to 1 end if run script ("tell application \"System Events\" to keystroke \"" & sp_no & "\"using control down") (* 上記の「\」を半角の「\」に直して下さい *) end tell
-- LargeType で Space Number を表示 delay 0.2 tell application "Quicksilver" to show large type "Space " & sp_no as text
--おまけ --say "Space " & sp_no
|
(前のSpaceへ移動)(* Go Previous Space *)
tell application "System Events" -- Spaces の総数を調べる tell expose preferences tell spaces preferences set sp_row to spaces rows set sp_clm to spaces columns set sp_all to sp_row * sp_clm end tell end tell -- 現在の Space Number を調べる tell process "SystemUIServer" tell menu bar 1 set mb to count (every menu bar item) repeat with i from 1 to mb tell menu bar item i if size = {34, 22} then try set sp_no_x to value as number if sp_no_x < 17 then set sp_no to sp_no_x end try end if end tell set i to i + 1 end repeat end tell end tell -- 前の Space へ移動 if sp_no > 1 then set sp_no to sp_no - 1 else set sp_no to sp_all end if run script ("tell application \"System Events\" to keystroke \"" & sp_no & "\"using control down") (* 上記の「\」を半角の「\」に直して下さい *) end tell
-- LargeType で Space Number を表示 delay 0.3 tell application "Quicksilver" to show large type "Space " & sp_no as text
--おまけ --say "Space " & sp_no
|
これは
Spaces機能で、次(前)のSpaceに移動し、Space番号を
Large Typeで表示するものです。
これを「
Abracadabra Triggers」を使ってマウスジェスチャに登録して使っています。
これを実行すると、下のように移動してSpace番号を表示します。

ちょっとウザイような気もするけど、「これでもか」と言わんばかりに表示されるので、どこのSpaceなのか分かり易く、思った以上に僕的にはいいです。
本当は「
Mouse Trigger」で登録して、マウスポインタを画面の端に持って行ったら次(前)のSpaceへ移動させようと考えて作ったものでしたが、Mouse Trigger と Spaces の相性が悪く、使い物になりませんでした。
このスクリプトはメニューバーに表示される現在のSpace番号を読み取り、移動するときには「control+数字キー」のショートカットを利用してspaceを移動するものです。
ですから、下のような設定条件がいろいろとあります。
まず、スクリプトエディタにコピペして
「\」を「\(バックスラッシュ)」の半角に直して保存して下さい。
半角の「\(バックスラッシュ)」は英数入力モードで
option+\ で入力できます。
それと、
システム環境設定>
ExposéとSpacesパネル>
Spacesタブ を開いて、下のように設定します。

・「
メニューバーに操作スペースを表示」にチェックする
・行、列を設定してスペースの総数を
9個以下に設定する
・Quicksilver を「
すべての操作スペース」に設定する
・操作スペースの切り替えを
control+数字キー に設定する
最後の「
control+数字キー」はスクリプトの方の赤字の「control」を変更すれば、他の修飾キーでもOKです。
また、システム環境設定の「ユニバーサルアクセス」パネルで
「
補助装置にアクセスできるようにする」にチェックを入れないと機能しません。

MenuExtraをたくさん表示させている場合は、ちゃんと動作しないかも。
また、ちゃんと動作しないことも時々あります。
AppleScriptに詳しい人ならもっとうまく処理できるんだろうけど、僕にはこれで精一杯です。
ついでに、メニューバーに表示されるSpace番号は小さくて読みづらいので、こんなものもTriggerのショートカットに登録して使っています。
(Space番号を表示)(* Show SpaceNumber *)
tell application "System Events" -- 現在の Space Number を調べる tell process "SystemUIServer" tell menu bar 1 set mb to count (every menu bar item) repeat with i from 1 to mb tell menu bar item i if size = {34, 22} then try set sp_no_x to value as number if sp_no_x < 17 then set sp_no to sp_no_x end try end if end tell set i to i + 1 end repeat end tell end tell end tell
-- LargeType で Space Number を表示 tell application "Quicksilver" to show large type "Space " & sp_no as text --おまけ say "Space " & sp_no
|
これはただ、Space番号をでっかく表示するだけのものです。おまけで喋ります。メニューバーに表示されている番号から読み取っているので、本末転倒なスクリプト。
それと需要があるか分からないけど、上下に移動するものも作ってみました。「行」が1行しかない場合は移動せず、Space番号を表示するのみになります。
(上のSpaceへ移動)(* Go Upper Space *)
tell application "System Events" -- Spaces の総数を調べる tell expose preferences tell spaces preferences set sp_row to spaces rows -- 縦 set sp_clm to spaces columns -- 横 set sp_all to sp_row * sp_clm -- 総数 end tell end tell -- 現在の Space Number を調べる tell process "SystemUIServer" tell menu bar 1 set mb to count (every menu bar item) repeat with i from 1 to mb tell menu bar item i if size = {34, 22} then try set sp_no_x to value as number if sp_no_x < 17 then set sp_no to sp_no_x end try end if end tell set i to i + 1 end repeat end tell end tell -- 上の Space へ移動 if sp_no > sp_clm then set sp_no to sp_no - sp_clm else set sp_no to sp_no + (sp_clm * (sp_row - 1)) end if run script ("tell application \"System Events\" to keystroke \"" & sp_no & "\"using control down") (* 上記の「\」を半角の「\」に直して下さい *) end tell
-- LargeType で Space Number を表示 delay 0.3 tell application "Quicksilver" to show large type "Space " & sp_no as text
--おまけ --say "Space " & sp_no
|
(下のSpaceへ移動)(* Go Lower Space *)
tell application "System Events" -- Spaces の総数を調べる tell expose preferences tell spaces preferences set sp_row to spaces rows -- 縦 set sp_clm to spaces columns -- 横 set sp_all to sp_row * sp_clm -- 総数 end tell end tell -- 現在の Space Number を調べる tell process "SystemUIServer" tell menu bar 1 set mb to count (every menu bar item) repeat with i from 1 to mb tell menu bar item i if size = {34, 22} then try set sp_no_x to value as number if sp_no_x < 17 then set sp_no to sp_no_x end try end if end tell set i to i + 1 end repeat end tell end tell -- 下の Space へ移動 if sp_no <= (sp_all - sp_clm) then set sp_no to sp_no + sp_clm else set sp_no to sp_no - (sp_clm * (sp_row - 1)) end if run script ("tell application \"System Events\" to keystroke \"" & sp_no & "\"using control down") (* 上記の「\」を半角の「\」に直して下さい *) end tell
-- LargeType で Space Number を表示 delay 0.3 tell application "Quicksilver" to show large type "Space " & sp_no as text
--おまけ --say "Space " & sp_no
|
Quicksilver用のスクリプトは下記のサイトでも公開されているので、いろいろ取り入れてみたら、Quicksilver の使い方が広がります。
・
How I use Quicksilver II: Scripts | jwdunn・
quicksilver:creations:scripts [docs]・
ウィンドウのサイズを変えたり位置を動かしたりするAppleScript を QuickSilverに登録すると快適 - hibomaのはてなダイアリー別に Quicksilver でなくとも、
Butler、
AmScriptsCMX、
Spark などを使えば、いろいろな方法でAppleScriptを実行することができます。
上記のスクリプトは、LargeTypeで表示させる部分を削除して別の方法(「say」「Display Dialog」「
Growl」など)で表示させれば、Quicksilver以外でも使えます。
次の記事では、上記スクリプトをGrowlで表示させるようにしてみます。
『
Quicksilver/ AppleScript でいろいろ操作(2)』につづく
この記事では Quicksilver(3815) を使用しています。
(ダウンロードリンク)
Site top page :
BlacktreeDownload page :
Blacktree(関連記事)
Quicksilver/ AppleScript でいろいろ操作(1)Quicksilver/ AppleScript でいろいろ操作(2)Quicksilver/ AppleScript でいろいろ操作(3)Quicksilver --- 基本的な概略説明
Quicksilver/ 基本的な使用例 Quicksilver/ Catalogの設定Quicksilver/ Actionについて(1)Quicksilver/ Actionについて(2)Quicksilver/ Actionについて(3)Quicksilver/ Actionについて(4)- Command ObjectsQuicksilver/ Triggers の説明(1)Quicksilver/ Triggers の説明(2)Quicksilver/ Plug-ins についてQuicksilver/ Proxy Objects についてQuicksilver/ Triggers の説明(3)- Mouse TriggersQuicksilver/ Triggers の説明(4)- Abracadabra TriggersQuicksilver/ ショートカットまとめすべてのQuicksilver記事のリンクは『
Quicksilver』の(関連記事)にあります。