2016-02-18 52 views
0

使用AppleScript我試圖從Scripts文件夾中調用另一個AppleScript時,我很困惑我做錯了什麼。我當前的腳本保存爲foo.app,我看到Bundle Contents的結構,但是當我嘗試從Scripts文件夾中撥打bar.app時,我得到一個對話框Resource not foundApplescript指示嘗試在應用程序內部調用時找不到資源

引用後「How to access from AppleScript a bundled file within a Cocoa-AppleScript Application?」我想:

tell application "Finder" 
    set thisFolder to (container of (path to me)) as string 
    set insideApp to thisFolder & (path to resource "bar.app") 
end tell 

時所產生我做了錯誤的更多一些搜索我引用「How do I get the Scripts folder in the application bundle?」,並試圖:

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

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文件夾中調用?

回答

0

有一種普遍的誤解:

path to me指向路徑的腳本(束)。
container of (path to me)指向路徑的腳本的包圍文件夾(束)

因此,它是:

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不是完全需要。

相關問題