I'm creating a program that will talk to iTunes using AppleScript for
a longer time. The user may be working with iTunes while my program
is going about its business, so I want to handle the situations when
iTunes may not respond to Apple Events. It seems that I can use the
AppleScript 'clause' (is that the right term?) 'with timeout of ...
seconds' to make this happen.
To test this I created a small application that executes the
following script:
get.applescript
===============
tell application "iTunes"
with timeout of 5 seconds
get version
end timeout
end tell
From my Cocoa application I execute this script in the following
manner:
To trigger the timeout behavior I choose 'Open...' in iTunes to show
the modal open panel.
Timing out seems to work fine most of the time _except_ when iTunes'
open panel is up the first time doScript: is executed. In that case I
have to sit through the entire default timeout period (2 minutes).
Not until the open panel is closed and the script executes once
without timeout does the desired 5 second timeout take effect.
Is this a bug (looks like it), and what is the general approach to
handling 'unresponsive' applications?