[Finder]UTIからアプリケーションを起動させる
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
set strUTI to "com.google.Chrome" as text
########処理分岐(スクリプトメニュー対策)
tell current application
set strName to name as text
end tell
if strName is "osascript" then
tell application "Finder"
###UTIからアプリケーションのパスを取得
set fileAppPath to application file id strUTI
###エリアス
set aliasAppPath to fileAppPath as alias
###UNIXパス
set strAppPath to POSIX path of aliasAppPath as text
###開く
open aliasAppPath
end tell
set ocidAppBundle to refMe's NSBundle's bundleWithPath:strAppPath
set ocidAppName to ocidAppBundle's objectForInfoDictionaryKey:"CFBundleDisplayName"
set strAppName to ocidAppName as text
tell application strAppName
launch
activate
end tell
return "Finderで起動しました"
else
set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
set ocidWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppBundlePathURL to ocidWorkspace's URLForApplicationWithBundleIdentifier:strUTI
set ocidAppBundle to refMe's NSBundle's bundleWithURL:ocidAppBundlePathURL
set strAppName to (ocidAppBundle's objectForInfoDictionaryKey:"CFBundleDisplayName") as text
#####アプリケーションを起動する
set ocidOpenConfiguration to refMe's NSWorkspaceOpenConfiguration's configuration()
ocidOpenConfiguration's setHides:ocidFalse
ocidOpenConfiguration's setRequiresUniversalLinks:ocidFalse
ocidOpenConfiguration's setActivates:ocidTrue
ocidWorkspace's openApplicationAtURL:ocidAppBundlePathURL configuration:(ocidOpenConfiguration) completionHandler:(missing value)
return "NSWorkspaceで起動しました"
end if
| 固定リンク
「Finder」カテゴリの記事
- [Finder] AppleScript で Finder 項目を選択する(新規FInder Windowを作って指定ファイルを選択)(2025.01.09)
- Dock再起動(2024.12.14)
- SystemUIServer再起動(Menu barほか)(2024.12.14)
- Finder再起動(2024.12.14)
- [Finder]エイリアスの参照元の取得(2024.12.02)
「UTType」カテゴリの記事
- シンボリックリンクのUTIの取得(2024.12.02)
- [UTType]処理対象のUTI(ファイルタイプ)か?チェックする 複数UTIでチェックする(2024.10.03)
- [UTType]処理対象のUTI(ファイルタイプ)か?チェックする(2024.09.30)
- UTI(uniform type identifier)の取得 ツリー構造付き 少し修正(2024.06.19)
- UTI(uniform type identifier)の取得 ツリー構造付き(2024.05.23)