2016-05-07 7 views
0

開いているドキュメントを常にチェックし、閉じたときにファインダにコメントを追加するコードがあります。Applescript/Photoshop - 何らかの「ビジー状態ならば待つ」コマンドですか?

「保存しますか?」などの問題がある場合は、問題が発生しています。または "Loading ..."が表示され、0と1の間のいくつかの変わったリムボがあり、正しく数えられないようです。それは一般的な "一般的なPhotoshopエラー"メッセージでクラッシュします。

「ビジーの場合は一時停止/待機する」コマンドなどがありますか?

repeat 

tell application "Adobe Photoshop CS6" 

    set D1 to count documents 

    local mainDocList 
    set mainDocList to {} 

    if ((count mainDocList) ≠ D1) then 
     log "Main Ran" 
     if (D1 > 0) then 
      set c to 1 
      repeat while (c ≤ D1) 
       set mainDocList to mainDocList & (file path of document c) 
       set c to c + 1 
      end repeat 
     end if 
    end if 

    delay 3 

    set D1 to count documents 

    local currentDocList 
    set currentDocList to {} 

    if ((count currentDocList) ≠ D1) then 
     log "Current Ran" 
     if (D1 > 0) then 
      set c to 1 
      repeat while (c ≤ D1) 
       set currentDocList to currentDocList & (file path of document c) 
       set c to c + 1 
      end repeat 
     end if 
    end if 


end tell 

local closedList, a 
set closedList to {} 
if ((count mainDocList) ≠ (count currentDocList)) then 
    repeat with a in mainDocList 
     set a to contents of a 
     if {a} is not in currentDocList then set end of closedList to a 
    end repeat 
end if 
log "∆: " & (count closedList) 
log "- - - - -" 


if ((count closedList) > 0 and ((count mainDocList) > (count currentDocList))) then 
    tell application "Finder" 
     set c to 1 
     repeat while (c ≤ (count closedList)) 
      tell application "System Events" 
       set modDate to modification date of (item c of closedList) 
      end tell 

      set theDate to current date 

      set Y to text -2 thru -1 of ("00" & (year of theDate)) 
      set M to text -2 thru -1 of ("00" & ((month of theDate) as integer)) 
      set D to text -2 thru -1 of ("00" & (day of theDate)) 
      set spartanDate to Y & M & D 

      set theTime to (time string of theDate) 
      set theTime to text -11 thru -7 of ("00" & (time string of theDate)) 

      set currentComments to (get comment of (item c of closedList)) 
      set comment of (item c of closedList) to currentComments & (" | USER-" & spartanDate & "-" & theTime) 
      log "******************COMMENTED" 
      set c to c + 1 
     end repeat 
    end tell 
end if 


end repeat 

答えて

0

コードにWHEREが表示されているように思われる場合は、うまくいきます。私の意見では、ファイルを扱っているApplescriptのコードは、try ... on error ... endブロックで自由に振りかざすべきです。

try 
    ... 
on error errMsg 
    display dialog "ERROR: " & errMsg 
end try 

問題がどこで発生したのかを特定し、エラーメッセージが表示されたら、問題を解決することができます。また

、あなたがポップアップするモーダルダイアログがタイムアウトブロックでそのコードを取り囲む、問題の一部であることが疑われる場合:

with timeout of 60000 seconds 
    ... could that could otherwise timeout 
end 

すべてのスクリプト文はタイムアウトの対象となり、そして悪いことは通常起こりますあなたがTRYブロックでタイムアウトをキャッチしていないか、TIMEOUTブロックを使ってタイムアウトを防ぐことができない場合は、

+0

今は気が気です。なんらかの理由でtry/errorブロックを追加しても、私の頭を越えていませんでした。私はすべてのカウントブロックの周りにエラーの遅延を追加し、すべてを修正しました。 ありがとうございます! – Pixel

+0

Pixelを歓迎します。私たちは時々助けが必要です。 –

関連する問題