【发布时间】:2015-10-06 22:16:37
【问题描述】:
我编写了一些 Applescript 来创建所有路径的列表 在 Dock 中运行的应用程序:
set appsRunning to [] tell application "System Events" repeat with p in every application process if background only of p is false then set appsRunning to appsRunning & POSIX path of (path to application p) end if end repeat end tell但是当它运行时我得到 错误 - “无法将应用程序转换为类型常量”,它 突出显示
path to application p。我不明白为什么会这样,因为当我跑步时
set q to POSIX path of (path to application "Finder") -- or any other application我没有收到任何错误,我明白了
"/System/Library/CoreServices/Finder.app/"在结果中返回 场地。我怎样才能让它工作?
附:就我的目的而言,获得路径是至关重要的—— 应用程序名称根本行不通。 (这是因为当我得到名字 申请过程中,我的一些申请是 SSB 使用Fluid 返回
"FluidApp"作为他们的 名称而不是"Gmail"或"Tumblr"或任何网站 我已经做成了一个应用程序。我需要区分这些和 只有当我得到路径时才会发生这种情况。)任何帮助将不胜感激!谢谢。
更新:我使用了@vadian's answer中第一个建议的修正版本来解决我的问题:
set appsRunning to {}
tell application "System Events"
repeat with aProcess in (get application file of every application process whose background only is false)
set appsRunning to appsRunning & POSIX path of aProcess
end repeat
end tell
【问题讨论】:
标签: macos types path applescript