移动应用程序时如何检测AppleScript?

时间:2015-10-19 03:02:45

标签: applescript

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

if (currency[i] == amount){
    return [1,i];

...

temp1 = findMinCoins(currency,j);
temp2 = findMinCoins(currency,amount - j);

if(temp1[0] + temp2[0] < min[0]){
    min = [temp1[0] + temp2[0]] concatenated with temp1[1..] and temp2[1..]

VVVV就在这里是错误

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"

^^^^这里是错误

    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"

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

1 个答案:

答案 0 :(得分:2)

在撰写本文时,您的代码不会编译,而是回答一般问题:

POSIX path of (path to me)

将从其中返回正在运行的基于AppleScript的应用程序的POSIX路径,包括尾随/;例如:"/Applications/MyAppleScriptApp.app/"

除此之外,在向shell命令字符串添加参数以便与quoted form ofdo script一起使用时,应始终使用do shell script,以确保将其保留为-is并且不会破坏整个shell命令。

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

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