2015-10-19 28 views
0

所以,我试图用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..."} 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" 

VVVV就在这里是错误

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应用程序? (这可能会更好地工作。)

回答

2

您的代码,张贴在撰写本文时,将不能编译,而是笼统地回答这个问题:

POSIX path of (path to me) 

将POSIX路径返回到正在运行的AppleScript其中包括尾随/;例如:"/Applications/MyAppleScriptApp.app/"


除此之外,你应该总是添加参数与do scriptdo shell script使用一个shell命令字符串时,以确保它保持原样,并没有按”使用quoted form of不会破坏整个shell命令。


此外,假设你的目的是简单地显示/捕获来自外壳命令的输出,使用do shell script,运行隐藏外壳命令并返回其标准输出输出;例如:

set cmdOutput to do shell script "ls" 
display alert "Files in current folder" message cmdOutput 
相关问题