Ich habe Code, der ständig nach offenen Dokumenten sucht und einen Kommentar im Finder hinzufügt, wenn er geschlossen wird.Applescript/Photoshop - Eine Art von "Warten, wenn beschäftigt" Befehl?
Ich habe ein Problem, dass, wenn etwas wie die "Möchten Sie speichern?" oder "Loading ..." erscheint, es ist ein merkwürdiger Limbo zwischen 0 und 1 und scheint nicht richtig zu zählen. Es stürzt dann mit der generischen "General Photoshop Error" Nachricht ab.
Gibt es einen Befehl "Pause/Wait If Busy" oder etwas anderes?
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
Ich fühle mich jetzt dumm. Aus irgendeinem Grund kam mir das Hinzufügen von "try/error" -Blöcken nicht einmal in den Sinn. Ich fügte eine Fehlerverzögerung um jeden Zählblock hinzu und das brachte alles in Ordnung. Vielen Dank! – Pixel
Gern geschehen, Pixel! Keine Notwendigkeit, sich dumm zu fühlen, wir brauchen alle von Zeit zu Zeit Hilfe. –