AppleScript名:Bundle IDで指定したアプリケーションのURL Schemeを求める |
— Created 2017-07-23 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" use BridgePlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html property |NSURL| : a reference to current application’s |NSURL| property NSBundle : a reference to current application’s NSBundle property SMSForder : a reference to current application’s SMSForder load framework set aRes to getURLSchemesFromBundleID("com.apple.Safari") of me –> {appName:"Safari", appBundleID:"com.apple.Safari", urlScheme:{"http", "https", "file"}} on getURLSchemesFromBundleID(aBundleID) set aURL to current application’s NSWorkspace’s sharedWorkspace()’s URLForApplicationWithBundleIdentifier:aBundleID if aURL = missing value then return false set bPath to (aURL’s |path|()) as string set aURLrec to getAppURLSchemes(bPath) of me return aURLrec end getURLSchemesFromBundleID on getAppURLSchemes(aP) set aURL to |NSURL|’s fileURLWithPath:(POSIX path of aP) set aBundle to NSBundle’s bundleWithURL:aURL set aDict to aBundle’s infoDictionary() set appNameDat to (aDict’s valueForKey:"CFBundleName") as string set bundleIDat to (aDict’s valueForKey:"CFBundleIdentifier") as string set urlSchemes to (aDict’s valueForKey:"CFBundleURLTypes") if urlSchemes is not equal to missing value then set urlList to urlSchemes’s valueForKey:"CFBundleURLSchemes" set urlListFlat to (SMSForder’s arrayByFlattening:urlList) as list else set urlListFlat to {} end if set aRec to {appName:appNameDat, appBundleID:bundleIDat, urlScheme:urlListFlat} return aRec end getAppURLSchemes |
(Visited 24 times, 1 visits today)