[CFBundleDisplayName]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
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
set strUTI to "com.google.Chrome" as text
tell application "Finder"
set fileAppPath to application file id strUTI
set aliasAppPath to fileAppPath as alias
set strAppPath to POSIX path of aliasAppPath as text
end tell
set ocidAppBundle to refMe's NSBundle's bundleWithPath:strAppPath
set ocidAppName to ocidAppBundle's objectForInfoDictionaryKey:"CFBundleDisplayName"
log ocidAppName as text
| 固定リンク
「NSBundle」カテゴリの記事
- [Plist]Acrobat ReaderのSCA(single client app) Unified App版判定(その2 AppleScript:ASOC)(2025.01.06)
- バンドルIDからアプリケーションの実行バイナリーへのパスを調べる(2024.12.30)
- バンドルIDからアプリケーションのバーション(Launch Services Register との相違のチェックも入れる)(2024.11.22)
- バンドルIDからアプリケーションのバーション(2024.11.22)
- バンドルIDからアプリケーションのパス(2024.01.24)
「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)