如何使AppleScript在移动其应用程序时进行检测?

如何使AppleScript在移动其应用程序时进行检测?,applescript,Applescript,因此,我试图用AppleScript创建一个应用程序,但当我将我的应用程序移动到另一个文件夹并运行它时,它总是会查看它以前所在的文件夹 display dialog "Kindle Fire HDX 7" Utility Mac Please select the action you want to do. Make sure a Terminal window is OPENED!!!" buttons {"Connected Devices", "Reboot", "More..."}

因此,我试图用AppleScript创建一个应用程序,但当我将我的应用程序移动到另一个文件夹并运行它时,它总是会查看它以前所在的文件夹

display dialog "Kindle Fire HDX 7" Utility Mac
Please select the action you want to do.
Make sure a Terminal window is OPENED!!!" 
buttons {"Connected Devices", "Reboot", "More..."} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Connected Devices" then
-- action for 1st button goes here
tell application "Terminal"
这里的VVV是错误的

    if (count of windows) is not 0 then
        do script "cd ~/Desktop/ADB-GUI/Kindle Fire HDX 7" Utility.app/Contents/Resources/minerboyadb/ && ./adb devices"
    end if
else if the button_pressed is "" then
-- action for 2nd button goes here
else
-- action for 3rd button goes here
end if
^^^^这就是错误

    if (count of windows) is not 0 then
        do script "cd ~/Desktop/ADB-GUI/Kindle Fire HDX 7" Utility.app/Contents/Resources/minerboyadb/ && ./adb devices"
    end if
else if the button_pressed is "" then
-- action for 2nd button goes here
else
-- action for 3rd button goes here
end if

有办法解决这个问题吗?或者可以使用Xcode制作AppleScript应用程序吗?(这可能会更好。)

在撰写本文时发布的代码不会编译,但要回答一般问题:

POSIX path of (path to me)
将从POSIX路径中返回运行中的基于AppleScript的应用程序的POSIX路径,包括尾部的
/
;e、 g.:
“/Applications/myapplescriptap.app/”


除此之外,在将参数添加到shell命令字符串以与
do script
do shell script
一起使用时,应始终使用
的引号形式,以确保它保持原样,不会破坏整个shell命令


此外,假设您的目的是简单地显示/捕获shell命令的输出,请使用
do shell script
,它运行隐藏的shell命令并返回其stdout输出;e、 g:

set cmdOutput to do shell script "ls"
display alert "Files in current folder" message cmdOutput