问题描述
限时送ChatGPT账号..使用 AppleScript 当我尝试从 Scripts
文件夹调用另一个 AppleScript 时,我对自己做错了什么感到困惑.我当前的脚本保存为 foo.app
并且我从 Bundle Contents
看到结构但是当我尝试从内部调用 bar.app
Scripts
文件夹我得到一个 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:关键词]
发布评论