在应用程序中使用applescript打开本地文件

时间:2013-09-11 18:19:56

标签: macos applescript

我如何从AppleScript应用程序中打开文件?我将它放在我的AppleScript应用程序的/Contents/Resources中。我想知道的是我会告诉实际的脚本吗?

1 个答案:

答案 0 :(得分:2)

要获取应用程序的路径,请使用path to me命令并构建资源的路径。然后,您可以使用Finder使用默认程序打开文件,也可以告诉特定程序打开文件。

set filepath to (path to me as string) & "Contents:Resources:file.ext"

tell application "Finder"
    open alias filepath
end tell

--OR

tell application "Microsoft Word"
    open alias filepath
end tell