I was wondering if anyone might have a script that does the following:
¢ Check iTunes if it’s downloading any files
¢ if the files are downloading do nothing.
¢ if no files are downloading then shutdown the computer.
-files would be any podcasts/movies/etc
Any help would be appreciated.
that sounded interesting to me, so I tried to do it …
The problem is, that only playlists and their contents are scriptable (as it seems to me) and so you can’t communicate with “iTunes Store”, “Shopping Cart” or “Downloads”.
Then I found out, that iTunes will give a warning dialog, if you try to quit while there are uncompleted downloads. And so there is in fact a possibility to script what you want to achive:
set wait_for_iTunes to true
if wait_for_iTunes then
with timeout of 3 seconds
tell application "iTunes" to quit
set wait_for_iTunes to false
-- as long as there are downloads, timeout will fail because iTunes still waits for userinteraction with the dialog ("really quit while downloading?")
tell application "System Events"
-- bring iTunes to front and dismiss the dialog. otherwise we can't tell if there are still running downloads the next time we check
set frontmost of process "iTunes" to true
keystroke (key code 53) -- the escape key (for "cancel")
return 10 -- check back in 10 seconds
-- if there were no downloads, iTunes will have quit without error and wait_for_iTunes will be "false"
tell application "Finder" to shut down
I tested the script only with Podcasts and hope it will work with other downloads too…
Hopefully this solves your problem
thanks creature. Greatly appreciate. I’ll give you some feedback to see how it works.