0
我想知道是否有方法使用AppleScript來確定當前的默認電子郵件應用程序是什麼。理想情況下,它會返回到程序的路徑,如/Applications/Mail.app
或/Applications/Outlook.app
。AppleScript可以確定默認郵件應用程序嗎?
我想知道是否有方法使用AppleScript來確定當前的默認電子郵件應用程序是什麼。理想情況下,它會返回到程序的路徑,如/Applications/Mail.app
或/Applications/Outlook.app
。AppleScript可以確定默認郵件應用程序嗎?
您可以從啓動服務首選項文件中識別默認電子郵件客戶端。
在El Capitan文件位於~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
。在10.11之前的系統版本中,該文件可能直接位於「首選項」文件夾中。
set bundleIdentifier to missing value
set LSPrefFilePath to (path to preferences folder as text) & "com.apple.LaunchServices:com.apple.launchservices.secure.plist"
tell application "System Events"
set LSPrefFile to property list file LSPrefFilePath
tell property list item 1 of contents of LSPrefFile
repeat with anItem in (get property list items)
if exists property list item "LSHandlerURLScheme" of anItem then
if value of property list item "LSHandlerURLScheme" of anItem is "mailto" then
set bundleIdentifier to value of property list item "LSHandlerRoleAll" of anItem
exit repeat
end if
end if
end repeat
end tell
end tell
if bundleIdentifier is missing value then
set defaultMailClient to "/Applications/Mail.app"
else
tell application "Finder" to set defaultMailClient to POSIX path of (application file id bundleIdentifier as text)
end if