Hi,
I am exploring the possibility of scripting the creation of smart playlists in iTunes. As I understand it this can only be achieved with GUI scripting. I have come across a couple of threads which suggest this can be achieved:
https://discussions.apple.com/thread/2083802?start=0&tstart=0
http://macscripter.net/viewtopic.php?id=9967
however both generate an error for me. The problem appears to be around the line “tell scroll area 1 of group 1 of window 1”. I get the error:
System Events got an error: Can’t get group 1 of window 1 of process “iTunes”. Invalid index.
I wonder if someone could help me get this working?
Thanks,
Nick
This works in Lion with iTunes 10.6.1
tell application "iTunes" to activate
tell application "System Events" to tell process "iTunes"
keystroke "n" using {option down, command down} -- New Smart Playlist.
delay 0.5
keystroke --"place your tabs and selections here."
delay 0.5
keystroke return & return -- click the "OK" button, then the "Yes" button
delay 0.5
keystroke "New smart playlist" & return -- to rename the playlist
end tell
I have found, however, that it seems to fail if you have selected any other already created playlists. The Selection needs to be hilighted on the MUSIC or MOVIES lists.
Model: iMac 21" i5
Browser: Firefox 12.0
Operating System: Mac OS X (10.7)