Selecting a user playlist as source in Itunes DJ

Hi,

I’m using iTunes 9 with Apple script version 2.3. I’m fairly newbie in applescript

I would like to select a user playlist, say called ‘Jazz’, that is built by myself, and change it as the source in iTunes DJ, with Apple script.

So far I have managed changing the iTunes window to ITunes DJ by:

tell application "iTunes"
set dj_playlist to some playlist whose special kind is Party Shuffle
-- ...and the source playlist for Jazz
-- ??? HERE
end tell

Is it possible? any help would appreciated. Thanks.
Indy

Hi,

I doubt it’s possible.
There is no property in the dictionary to change the source.
You can change the value with GUI scripting but the view doesn’t update

Thanks Stefan,

Do you have an example? I’m googling around but being a newbie in apple script makes GUI scripting more confusing.

/Indy

Here’s an example


tell application "iTunes"
	activate
	set view of browser window 1 to playlist "iTunes DJ"
end tell

tell application "System Events"
	tell process "iTunes"
		tell pop up button 1 of splitter group 1 of window "iTunes"
			click
			delay 0.2
			set value of attribute "AXValue" to "Jazz"
		end tell
	end tell
end tell

the usual methods to simulate pressing arrow keys and picking a menu item don’t work

After playing a little bit. It seems that although graphically it looks alright. Functionality wise it doesn’t work.
The source is changed to Jazz but the songs are still automatically added from the previous source, no matter what it is.

Additionally, although a bit out of scope, the script works if it’s run in applescript editor. But if it’s run in objective-c using NSScript object, it fails. I believe it has something to do with access for assistive devices. I need to experiment a bit more though. If anyone has similar experience, any comment would be appreciated.

just for info, All my code is based on cocoa and objective c and only when necessary, scripts are run via NSScript objects.