【问题标题】:Applescript path to application using variable使用变量的应用程序的 Applescript 路径
【发布时间】:2009-08-01 03:58:01
【问题描述】:

如果我有这样的applescript sn-p

tell application "Finder"
set thePath to (POSIX path of (path to application "MyApp"))
end tell

它会回到我身边

"/Applications/MyApp.app"

现在,我似乎无法弄清楚如何通过变量而不是文字来指定“MyApp”。

我的 applescript 读入了一些 XML 值,其中之一是我感兴趣的应用程序的名称。我试过这个:

tell application "Finder"
set thePath to (POSIX path of (path to application someVariable))
end tell

但这只是告诉我错误

“Finder 出错:无法将应用程序“MyApp”转换为类型常量。”

有什么想法可以做到这一点吗?

【问题讨论】:

    标签: applescript


    【解决方案1】:

    答案(或至少一个答案)是:

    set theApp to "MyApp"
    set pathToTarget to POSIX path of (path to application theApp)
    

    由于应用程序路径是标准添加的一部分,因此不需要 Finder。

    感谢 MacScripter 上的 Stephan K 让我明白这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-22
      • 2017-08-23
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      相关资源
      最近更新 更多