Check if a Mac OS X application is present

前端 未结 3 1788
轻奢々
轻奢々 2021-02-03 12:29

I recall there being a Cocoa framework or AppleScript dictionary to check if an Application bundle with a specific name is installed at all, anywhere on the computer.

Ho

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-03 13:29

    You can also use lsregister.

    on doesAppExist(appName)
        if (do shell script "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep com.apple.Safari") ¬
        contains "com.apple.Safari" then return true
    end appExists
    

    That's pretty fast and you can do it from other languages like Python quite easily. You would want to play around with what you grep to make it most efficient.

提交回复
热议问题