Re: iTunes 6.04 (OS 10.4.11) 'Applescript timed out' error - EVEN WITH 'with timeout' clause
Re: iTunes 6.04 (OS 10.4.11) 'Applescript timed out' error - EVEN WITH 'with timeout' clause
- Subject: Re: iTunes 6.04 (OS 10.4.11) 'Applescript timed out' error - EVEN WITH 'with timeout' clause
- From: "Stockly, Ed" <email@hidden>
- Date: Fri, 21 May 2010 13:02:02 -0500
- Acceptlanguage: en-US
- Thread-topic: iTunes 6.04 (OS 10.4.11) 'Applescript timed out' error - EVEN WITH 'with timeout' clause
Title: Re: iTunes 6.04 (OS 10.4.11) 'Applescript timed out' error - EVEN WITH 'with timeout' clause
>>>>I've got an Applescript (based on one of the many from Dough's Applescript collection) that gives a timeout out error in iTunes 6.04 on Tiger 10.4.11 with the following script - even though I have a 'with timeout..' clause (which I assume prevents this).
‘with Timeout’ doesn’t prevent the error, it just extends the amount of time applescript will wait for the result from an apple event.
With timeout of 600
-- do your stuff
End timeout
Will wait 10 minutes before an error.
>>>>This isn't the full script - it's just the convert command the causes the error (commenting the convert command makes the script run fine).
Some apps can get confused and report a timeout when there’s really another error. You have is a fairly old version of iTunes and that’s what I think is happening. See below.
>>>For any Apple people monitoring this - why doesn't Applescript have mechanism so a script can wait until something is done? With cocoa and delegate messages, this seem like it should easy - although implementing it in the on the applescript language side might be tough.
That’s the default behavior. The way it’s designed, an applescript command generates an appleEvent which is sent to an application. Applescript will then wait (2 minutes by default) for the application to send an appleEvent result.
But, there are some commands that don’t generate a result, and there are some applications that don’t play well with apple events.
In the dictionary of my version of iTunes, the convert command is expecting a list of tracks, and you’re sending it a single track.
If you wrap the item to be converted in {} it may work. (The error message I’m getting says it can’t get item 1 of ...., which tells me it’s looking for a list)
But, OMM if the convert doesn’t work, iTunes generates an error in the UI, which is not trapped by on error block
: (
Give the modified script below a shot.
HTH,
ES
tell application "iTunes"
-- which tracks
set selectedTracks to selection
-- convert/import selected tracks
with timeout of 3000 seconds
repeat with thisTrack in selectedTracks
try
-- convert the track
set newT to item 1 of (convert {thisTrack})
--set newT to thisTrack
on error m number n
if n is -1728 then
activate
my alert_user_and_cancel("User Canceled.")
end if
my alert_user_and_cancel((n as string) & " " & m)
end try
end repeat
end timeout
if frontmost is true then
try
if gave up of (display dialog "Done!" buttons {"Thanks"} ¬
default button 1 with icon 1 giving up after 300 with title my_title) ¬
is true then return
end try
end if
end tell
to alert_user_and_cancel(message)
tell application "iTunes"
display dialog message buttons {"Quit"} cancel button "Quit" default button 1 with icon 0 with title my_title
end tell
end alert_user_and_cancel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden