I'm writing a script in iTunes, part of which changes the selected playlist. When I'm all done, I want to restore the playlist and the selected tracks. I was able to do the first, but haven't found a way to do the last (and I'd really rather not use UI scripting and keyboard automation to achieve it). Here's what I've got that's working:

tell application "iTunes"
    -- Save the original playlist and selection
    set originalPlaylist to view of front window
    set originalSelection to selection

    -- go on and select some other playlist
    delay 5

    set view of front window to originalPlaylist
    -- something like this, which doesn't work:
    -- set selection to originalSelection
end tell


tell application "iTunes"
    set originalSelection to first item of selection
    delay 5
    reveal originalSelection
end tell
  • Thanks, I had only tried reveal on the entire selection, which throws an error. It's not as good as selecting the entire range, but it's a start. – Dov Mar 15 '13 at 23:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .