0

我想在 Application 文件夹中搜索已安装的应用程序,但下面的代码无法做到这一点,请建议我正确的方法。

tell application "Finder"

    if folder "Applications" of startup disk contains "Safari" then
        return true
    else
        return false
    end if
end tell

我得到了现有应用程序的 chk 代码,如果应用程序不存在在这种情况下,AppleScript 会弹出一个标题为“选择应用程序”的对话框,询问“AppYouDontHave 在哪里?”,请更正。

修改代码

tell application "Finder"
    if application "Safari" exists then
        tell application "Safari"
            set safariVersion to version
            return version
        end tell
    else
        false
    end if
end tell
4

1 回答 1

0

获取身份证

get id of application "Safari"

返回“com.apple.Safari”

  try
        exists application id "com.apple.Safari"
    on error
        return false
    end try

这应该解决您修改后的评论:

try
    tell application "Finder" to set theApp to get first item of folder "Applications" of the startup disk whose name is "Safari.app"
on error
    return false
end try
version of theApp
于 2012-09-05T12:10:42.827 回答