问题描述
玩AppleScript时,当我尝试从Scripts
文件夹调用另一个AppleScript时,我对自己做错的事情感到困惑.我当前的脚本另存为foo.app
,我从Bundle Contents
中看到了结构,但是当我尝试从Scripts
文件夹中调用bar.app
时,会出现一个Resource not found
对话框.
Playing with AppleScript I am confused on what I am doing wrong when I try to call another AppleScript from the Scripts
folder. My current script is saved as foo.app
and I see the structure from the Bundle Contents
but when I try to call bar.app
from inside the Scripts
folder I get a dialog of Resource not found
.
在引用"之后如何从AppleScript访问Cocoa-AppleScript应用程序中的捆绑文件?"我尝试过:
tell application "Finder"
set thisFolder to (container of (path to me)) as string
set insideApp to thisFolder & (path to resource "bar.app")
end tell
当产生错误时,我进行了更多搜索,我引用了""并尝试:
When that produced the error I did some more searching I referenced "How do I get the Scripts folder in the application bundle?" and tried:
tell application "Finder"
set thisFolder to (container of (path to me)) as string
set insideApp to (thisFolder as alias) & (path to resource "bar.app" in directory "Scripts")
end tell
定位description.rtfd
我显示变量thisFolder
和显示的对话框Macintosh HD:Users:darth_vader:Desktop:
,但是运行时它会生成Resource not found
:
Targeting description.rtfd
I display the variable thisFolder
and the dialog I get Macintosh HD:Users:darth_vader:Desktop:
but it produces Resource not found
when I run:
tell application "Finder"
set thisFolder to (container of (path to me)) as string
display dialog thisFolder
set insideApp to thisFolder & (path to resource "Contents:Resources:description.rtfd")
end tell
我到底在做什么错?如何在Scripts
文件夹中打电话?
What exactly am I doing wrong and how do I call from within the Scripts
folder?
推荐答案
普遍存在误解:
path to me
指向脚本的路径(捆绑包).container of (path to me)
指向脚本所在的文件夹(捆绑包)的路径
path to me
points to the path to the script (bundle).container of (path to me)
points to the path to the enclosing folder of the script (bundle)
就是这样:
set insideApp to path to resource "bar.app"
或:
set insideApp to path to resource "bar.app" in directory "Scripts"
或(首选)
set insideApp to alias ((path to me as text) & "Contents:Resources:description.rtfd")
根本不需要Finder
.
这篇关于Applescript表示尝试在应用程序内调用时找不到资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!