Applescript表示尝试在应用程序内调用时找不到资源 [英] Applescript indicates resource not found when trying to call within inside the app

查看:105
本文介绍了Applescript表示尝试在应用程序内调用时找不到资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

玩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表示尝试在应用程序内调用时找不到资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆