bgpict2.png 
わかばマークのMacの備忘録
初心者による Mac OSX の便利な使い方や、ソフトウェアの紹介など、Macのこといろいろ。

2023 / 12

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-502.html

Quicksilver/ AppleScript でいろいろ操作(3)
icn_Quicksilver
Quicksilver : ランチャ+システムの一部のような総合ユーティリティ
OS10.4以上(UB)、OS10.3.9 各対応
ドネーションウェア


Quicksilver/ AppleScript でいろいろ操作(2)』のつづき


今回は「Mouse Trigger」「Abracadabra Trigger」に登録して使うと便利そうなものを採り上げます。
おさらいの意味も含めて、前に採り上げたAppleScriptも再度、採り上げます。

icn_ScriptEditor
これらのスクリプトは、スクリプトエディタを開いてコピペして、
/Users/登録アカウント名/Library/Scripts/
などの場所に保存して下さい。


また 下記のAppleScriptのほとんどは、システム環境設定の「ユニバーサルアクセス」パネルで
補助装置にアクセスできるようにする」にチェックを入れないと機能しません。
071105is4





【 DejaMenu を呼び出す AppleScript 】


正確に言えば、「DejaMenu を呼び出す為のホットキー」を入力するものです。

tell application "System Events"
keystroke "m" using {command down, shift down}
end tell
※ホットキーが「shift+command+M」の場合です。別のものに設定している場合は赤字のところ適当に変更して下さい。

Mouse Trigger でこのスクリプトを登録すると、マウスボタンで DejaMenu を呼び出すことができて便利です。
070716djm6





【 Webブラウザで 進む・戻る を実行する AppleScript 】


Safari、Firefox、Camino、Siira でページの 進む・戻る を実行するものです。Abracadabra Trigger でマウスジェスチャに登録しておくと便利です。

(次のページへ進む)
-- Go Forward
set current_app to short name of (info for (path to frontmost application))
set web_browser to "Safari, Firefox, Camino, Shiira"
(* 他のブラウザを使う場合は↑ここのブラウザ名を変更 *)

if web_browser contains current_app then
tell application current_app to activate
tell application "System Events" to keystroke "]" using command down
else
beep
end if


(前のページへ戻る)
-- Go Back
set current_app to short name of (info for (path to frontmost application))
set web_browser to "Safari, Firefox, Camino, Shiira"
(* 他のブラウザを使う場合は↑ここのブラウザ名を追加・変更 *)

if web_browser contains current_app then
tell application current_app to activate
tell application "System Events" to keystroke "[" using command down
else
beep
end if





【 FinderでQuickLookを実行する AppleScript 】


QuickLookを実行するものです。
Mouse Trigger で登録して、マウスボタンでQuickLook表示させるといったことができます。
-- Activate QuickLook
set current_app to short name of (info for (path to frontmost application))
if current_app = "Finder" then
tell application "Finder" to activate
tell application "System Events" to keystroke "y" using command down
end if





【 すべてのFinderウインドウをDockにしまう AppleScript 】


option+command+M 、optionキーを押しながらFinderウインドウ左上の黄色ボタンを押すのと同じです。マウスジェスチャやホットコーナーなどに設定しておくと便利です。
-- Put All-Finder-Windows away in the Dock
set current_app to short name of (info for (path to frontmost application))
if current_app = "Finder" then
tell application "Finder"
if (count of windows) > 0 then set collapsed of every Finder window to true
end tell
end if



ちなみに逆バージョンの「Dockに収納したすべてのFinderウインドウを表示する」ものは下のようになります。
(「true」と「false」が違うだけ)
-- Show All-Finder-Windows
set current_app to short name of (info for (path to frontmost application))
if current_app = "Finder" then
tell application "Finder"
if (count of windows) > 0 then set collapsed of every Finder window to false
end tell
end if

※上記のスクリプトは、デフォルトで入ってるサンプルスクリプトをちょっと弄っただけのものです。




【 新規Finderウインドウを表示する AppleScript 】


Finderでの command+N のショートカットを実行するものです。
マウスジェスチャに登録しておくと便利です。
-- Open New Finder-Window
set current_app to short name of (info for (path to frontmost application))
if current_app = "Finder" then
tell application "Finder" to activate
tell application "System Events" to keystroke "n" using command down
end if





【 最前面のFinderウインドウのクローンを開く AppleScript 】


Clone Windowとほぼ同じ働きをします。最前面のFinderウインドウと同じウインドウをちょっと右下にずらして開きます。
マウスジェスチャに登録しておくと便利。
というより、アプリケーションとして保存してFinderのツールバーに登録した方がいいかも。
--- Open Clone Finder-Window
set current_app to short name of (info for (path to frontmost application))
if current_app = "Finder" then
tell application "Finder"
try
set theWindow to target of front window
set {a_x, a_y, b_x, b_y} to bounds of window 1
make new Finder window
set bounds of window 1 to {a_x + 40, a_y + 40, b_x + 40, b_y + 40}
set target of front window to theWindow
on error
display dialog "Finder-Window is NOT open." buttons "OK" default button 1 with icon caution
end try
end tell
end if
('08/03/17修正)

Clone Window を使っている人なら、
・Object「Clone Window」
・Action「Open」
としてTriggerに登録すれば、同じです。
071023qs347



もし、アプリケーションとして保存して、Finderのツールバーとかに登録しておくなら、最前面アプリを判定するところを削除しないと、うまく動作しないようです。
-- Open Clone Finder-Window (Application)
tell application "Finder"
try
set theWindow to target of front window
set {a_x, a_y, b_x, b_y} to bounds of window 1 of application "Finder"
make new Finder window
set bounds of window 1 to {a_x + 40, a_y + 40, b_x + 40, b_y + 40}
set target of front window to theWindow
on error
display dialog "Finder-Window is NOT open." buttons "OK" default button 1 with icon caution
end try
end tell
('08/03/17修正)
※初回起動時はかなり動作が遅いです。





【 Finderで選択しているものをゴミ箱に移動する AppleScript 】


Finderの最前面のウインドウで選択しているものをゴミ箱に移動するものです。

このスクリプトを実行すると、Finderの最前面のウインドウで選択しているファイル・フォルダをゴミ箱に移動してもいいかどうかの確認ダイアログが表示されます。
071023qs348

「OK」ボタンをクリックするか、returnキー で、ゴミ箱に移動します。Finderがアクティブなときしか機能しません。
また、実行したときに最前面のFinderウインドウで何も選択していない場合は、Beep音を鳴らします。
-- Move to Trash (Caution)
set current_app to short name of (info for (path to frontmost application))
if current_app is "Finder" then

tell application "Finder"
set select_item to selection
set every_item to every item of select_item
set count_item to count items of every_item

if count_item > 0 then
set carriage_return to return as text
try
set messeage to (count_item as string) & " 個のアイテムを" & carriage_return & "ゴミ箱 に移動しようとしています。" & carriage_return & carriage_return & "本当によろしいですか?"
display dialog messeage with icon caution
delete every_item
end try
else
beep
end if
end tell

end if


マウスジェスチャに登録しておくと、以前に muta's mac scribblingさん で紹介されていた『ScrubDelete X』というソフトと同じようなことができます。

ただし、ジェスチャ開始のときにマウスボタンを押すように設定している場合は、Finderで選択しているものが解除されたりするので、非常にやりにくいです。

そういうときは Mouse Trigger でマウスボタンに設定すると使い易いです。
Triggerでマウスボタンに登録する項目が多いので、5ボタンマウスじゃちょっとつらくなってきた・・・。





【 iTunesのウインドウを拡大・縮小する AppleScript 】


iTunesのウインドウを拡大・縮小する AppleScript です。マウスジェスチャに登録しておくと便利です。
071023qs349

正確に言えば、control+command+Z のショートカットを入力するものです。iTunes が最前面のときしか機能しません。

-- iTunes-Window is expanded/reduced
set current_app to short name of (info for (path to frontmost application))
if current_app is "iTunes" then
tell application "iTunes" to activate
tell application "System Events" to keystroke "z" using {control down, command down}
end if





【 iTunesのVisualizerを表示する AppleScript 】


iTunesのVisualizerを表示する AppleScript です。マウスジェスチャやホットキーに登録しておくと便利です。
071023qs350

iTunesが起動していないときは、このスクリプトを実行しても機能しません。また、iTunesが最前面のアプリケーションでなくとも機能します。

実行すると、フルスクリーンでVisualizerを表示します。
隠している状態などからでも、一気にフルスクリーンのVisualizerを表示します。
-- iTunes Show Visualizer
tell application "System Events"
set process_app to short name of every process
if process_app contains "iTunes" then
tell application "iTunes"
activate
set minimized of window 1 to false
set visuals enabled to true
set full screen to true
end tell
end if
end tell

ただ、普通にiTunesを最前面にして command+T を押した方が早いかも・・・。





上記のAppleScriptは、別に Quicksilver でなくとも、ButlerAmScriptsCMXSpark などを使えば、いろいろな方法で実行することができます。
もちろん、スクリプトメニューからも実行できます。

Quicksilver のTriggerに登録して使うと便利(かもしれない)という代物で、ただのAppleScriptです。





この記事では Quicksilver(3815) を使用しています。


(ダウンロードリンク)
Site top page : Blacktree
Download 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 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』の(関連記事)にあります。

edit

Quicksilver | CM:0 | TB:0

tag : Quicksilver  AppleScript 

+



管理者にだけ表示を許可する
 

trackback URL