2013-06-29 43 views
0

我有一個使用「SKProgressbar」的應用程序。我正在尋找這個進度條增加10 基於在其中運行的第二個shell腳本的進程。我不確定這是否可能。我已經提供了下面的腳本。我是新來的。在AppleScript中遞增進度條

on open adisk 
    set terminalcommand to "cd " & quoted form of (POSIX path of adisk) & " ; find . -name '.DS_Store' -type f -delete" 
    do shell script terminalcommand 
    set xxx to "cd " & quoted form of (POSIX path of adisk) & " ; find * -type f -exec md5 -r {} \\; > *New_File.md5" 
    set iconPath to ((path to me) as text) & "Contents:Resources:droplet.icns" 

    tell application "SKProgressBar" 
     activate 
     set floating to false --> default is true 
     set position to {500, 550} --> default is {1000, 750}, origin point is bottom left 
     set width to 400.0 --> default is 500.0 
     set title to "CreateMD5" 
     set header to "Processing..." 
     set header alignment to center 
     set footer to "" --> default is empty string 
     set footer alignment to center --> default is left 
     -- image path can be HFS or POSIX path, default is missing value (no image) 
     set image path to iconPath 
     tell progress bar 
      set minimum value to 0.0 --> default is 0.0 
      set maximum value to 100.0 --> default is 100.0 
      set current value to 0.0 --> default is 0.0 
     end tell 
     set show window to true --> default is false 
     tell progress bar 
      set indeterminate to false --> default is true 
      start animation 
      increment by 10.0 
      do shell script xxx 
      stop animation 
     end tell 
     quit 
    end tell 
    activate 
    display dialog "  MD5 Complete!" with icon 1 buttons {"Close", "Open Directory"} cancel button 1 default button 2 
    tell application "Finder" 
     open adisk 
    end tell 
end open 

對此的任何幫助將是偉大的。如果簡單的答案是否定的,那麼我會繼續前進並試圖找出一些東西。

+0

我不認爲有任何辦法知道一個shell腳本的進步,所以我懷疑你能做到這一點。一般而言,您只需在shell腳本之前啓動一個不確定的進度條,然後停止它。 – regulus6633

+0

謝謝。經過更多研究和您的迴應後,我發現這是唯一可行的選擇。這比我現在擁有的更好:) –

回答

0

我不熟悉SKProgressbar是如何工作的,但是如果它在腳本結束後沒有重置所有內容,難道你不能逆轉整個過程嗎?與其試圖從applescript內運行bash腳本,爲什麼不製作一個單獨增加欄的applescript,然後讓bash腳本在整個代碼中調用它?

例如。

#/Users/user_name/Desktop/update_progbar.scpt 
on run() 
    tell application "SKProgressBar" 
     activate 
     tell progress bar 
      increment by 10.0 
     end tell 
    end tell 
end 

然後

#!/bin/bash 
#/Some/Location/my_bash_script.sh 
for x in {1..10}; do 
    #do stuff here 
    osascript /Users/user_name/Desktop/update_progbar.scpt 
done