applescript - 如何从 Applescript 启动特定版本的 Illustrator?
问题描述
我安装了两个版本的 Illustrator,Adobe Illustrator 2020 和 Adobe Illustrator CC 2019。如何从 Applescript 确保选择了 Adobe Illustrator CC 2019?
为此,我进行了以下 applescript 编码,但 applescript 会自动更改应用程序名称。
set theResult to every paragraph of (do shell script "mdfind 'kMDItemContentTypeTree == \"com.apple.application\"c' | sort")
set systemApps to {}
set applicationsApps to {}
set Version2019 to "" as string
set Version2020 to "" as string
repeat with i from 1 to number of items in theResult
set end of systemApps to item i of theResult
if item i of theResult contains "Adobe Illustrator CC 2019" then
set end of applicationsApps to item i of theResult
set Version2019 to "true" as string
exit repeat
end if
end repeat
repeat with i from 1 to number of items in theResult
set end of systemApps to item i of theResult
if item i of theResult contains "Adobe Illustrator 2020" then
set end of applicationsApps to item i of theResult
set Version2020 to "true" as string
exit repeat
end if
end repeat
--display dialog (Version2019)
tell application "Finder"
if (Version2019 contains "true" and Version2020 contains "true") then
--display dialog "hey! " & theUser & return & return & "Adobe Illustrator 2019 and Adobe Illustrator 2020 available in this Mac" buttons {"Ok"}
set questionStudio to display dialog "hey! " & return & return & "Adobe Illustrator 2019 and Adobe Illustrator 2020 available in this Mac." & return & return & "Please select Version:" buttons {"Adobe Illustrator CC 2019", "Adobe Illustrator 2020", "Cancel"}
set answerStudio to button returned of questionStudio
if answerStudio contains "Adobe Illustrator 2020" then
tell application "/Applications/Adobe Illustrator 2020/Adobe Illustrator.app"
if it is not running then launch
end tell
it is running
return 0
else if answerStudio contains "Adobe Illustrator 2019" then
tell application "/Applications/Adobe Illustrator CC 2019/Adobe Illustrator.app"
if it is not running then launch
end tell
it is running
return 0
else if answerStudio contains "Cancel" then
tell me to quit
end if
else if (Version2019 contains "true") then
--tell application "Finder"
set appVersion to "Adobe Illustrator 2019"
--end tell
else if (Version2020 contains "true") then
--tell application "Finder"
set appVersion to "Adobe Illustrator 2020"
--end tell
end if
end tell
解决方案
使用应用程序的完整路径,而不仅仅是其名称。
另请注意,Finder 中显示的应用程序名称可能不是其真实文件名。
获取应用程序完整路径的最简单方法是将其图标拖放到脚本编辑器窗口中。
例子:
tell application "/Applications/Adobe Illustrator 2020/Adobe Illustrator.app"
…
end tell
推荐阅读
- php - PHP 中的 HTTP POST
- mysql - 查找所有具有相同关键字的产品
- php - 如果文件未重命名,Ajax ping php 不起作用
- r - 是否有一个基本的 R 函数可以通过多列查找两个 data.frame 的公共元素?
- python - 在哪里在线托管 selenium python 脚本?
- asp.net - 在 ASP.NET Core 中上传文件图像
- excel - 在 VBA 中显示多个模式用户窗体
- shell - 如何执行 docker-compose “pre-”down 脚本?
- java - Drools Agenda Group 似乎总是并行运行
- android - 为什么 Layout Gravity 在 Android Studio 中不起作用?