Search code examples
macosapplescriptitunesplaylist

How do I tell iTunes to display the Downloads "playlist" with AppleScript (on Mac OS X)?


I select certain playlists in iTunes so frequently that I've created AppleScripts to display them, and then bound them to keyboard shortcuts with FastScripts.

Here's an AppleScript for displaying my "New Podcasts" playlist:

tell application "iTunes"
    set view of (browser window 1) to user playlist "New Podcasts"
end tell

And here's an AppleScript for displaying "Music":

tell application "iTunes"
    set view of (browser window 1) to user playlist 1
end tell

I'd like to be able to go to "Downloads" (while new podcasts are downloading), but I can't figure out how to do it from an AppleScript. I've tried set view of (browser window 1) to user playlist 1 with various numbers instead of 1, and set view of (browser window 1) to user playlist "Downloads", but none of these work. I don't see any sign of Downloads in the iTunes AppleScript Dictionary.

Is it possible to set the view to "Downloads" from AppleScript? How?


Solution

  • tell application "System Events" to tell process "iTunes"
        tell outline 1 of scroll area 2 of window "iTunes"
            set statictexts to value of static text of rows
            repeat with i from 1 to number of statictexts
                if ((item i of statictexts) as text) starts with "Downloads" then
                    set value of attribute "AXSelected" of row i to true
                    return
                end if
            end repeat
        end tell
    end tell