Huub van Eijndhoven
Huub van Eijndhoven

Reputation: 41

applescript - how to access the clipboard as an iTunes track or file track object

I'm trying to dev a custom paste script for iTunes. After 'copy'' of some playlist tracks, the user should call the script in stead of standard paste, to paste the tracks into another playlist. The script will do some extra stuff apart from pasting the tracks.

Question: To paste the clipboard as tracks an iTunes playlist I need to find the clipboard contents as Track class objects, not the file names, furl's or whatever.

clipboard info

says it has the following in the clipboard:

{
    {Unicode text, 776},
    {string, 388},
    {«class itun», 4036},
    {«class furl», 118},
    {«class ut16», 778}
}

Now, the class furl objects might point me to the files, but that still doesn't get me an iTunes "File Track" or a "Track". Is there anyone who can shed some light on what the class "itun" things are which are on the clipboard? (Tried for a day to find out myself, but didn't get anywhere) And, whether itun class objects might be usable to get to the copied-to-the-clipboard tracks?

Upvotes: 1

Views: 189

Answers (1)

regulus6633
regulus6633

Reputation: 19032

I don't know how to do what you're asking using the clipboard. But why use the clipboard at all? If someone wants to "copy" the tracks this assumes that they have first selected the tracks. And if they have the tracks selected then there is no need to perform the copy step. A simple applescript can get the selection from iTunes so why not just use that approach? You get the selection as tracks and then do whatever you need in the rest of the applescript.

tell application "iTunes"
    set selectedTracks to the selection

    -- do whatever else you need
end tell

Upvotes: 0

Related Questions