尝试在应用程序内部调用时,Applescript 指示未找到资源

编程入门 行业动态 更新时间:2024-10-27 02:26:34
本文介绍了尝试在应用程序内部调用时,Applescript 指示未找到资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

使用 AppleScript 当我尝试从 Scripts 文件夹调用另一个 AppleScript 时,我对自己做错了什么感到困惑.我当前的脚本保存为 foo.app 并且我从 Bundle Contents 看到结构但是当我尝试从内部调用 bar.appScripts 文件夹我得到一个 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

当产生错误时,我做了更多的搜索,我引用了如何获取应用程序包中的 Scripts 文件夹?" 并尝试:

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: 但它产生资源未找到当我运行时:

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) 指向脚本(bundle)的封闭文件夹的路径

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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 15:02:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/915701.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   未找到   指示   资源   Applescript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!