LaunchBar: アプリを再起動するスクリプト

アプリケーションにプラグインをインストールして、プラグインを有効にするためにアプリケーション本体を再起動するような場面があると思います。こんな時に役立つ再起動スクリプトです。

-- Script to relaunch an app using LaunchBar
--  FredB http://geekthang.com
 
open location "x-launchbar:hide"
on open inputFiles
	try
		set inputFile to (POSIX path of ((first item of inputFiles) as string))
		set appName to do shell script "basename -s .app " & quoted form of inputFile
		tell application appName to quit
 
		repeat 50 times
			tell application "System Events"
				if (exists process appName) then
					delay 0.3
				else
					exit repeat
				end if
			end tell
		end repeat
 
		tell application appName to activate
	end try
end open

スクリプトエディタでコンパイルして、適当な場所(e.g. ~/Library/Scripts/LaunchBar/)に保存します。

This entry was posted in Apple and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">