with timeout of 5 * 3600 + 60 seconds
if something then
tell me to log "wait 5 h: " & (current date)
delay 5 * 3600
tell me to log "done: " & (current date)
display dialog "hello world" giving up after 30
else
log "failed"
end if
end timeout
It started 10:57 and was done 18:13. Why? The computer was awake the whole period.
How were you running the code?
Was it using “Script Editor”?
if so was Script Editor frontmost the entire time?
If not the display dialog timeout doesn’t start till it gets focus.
try this…
set something to true
with timeout of 5 * 3600 + 60 seconds
if something then
tell me to log "wait 5 h: " & (current date)
delay 5 * 3600
tell me to log "done: " & (current date)
tell me to activate
display dialog "hello world" giving up after 15
else
log "failed"
end if
end timeout