Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create an iTunes Genius playlist via keyboard shortcut' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create an iTunes Genius playlist via keyboard shortcut
Authored by: hrko on Sep 13, '10 03:34:09PM
Late to the party, I know, but maybe more people are looking for something like this. I am new to AppleScript so I am not sure this is the most elegant solution but it works for (iTunes X on Snow Leopard). This might create some errors if you dont have a track selected/playing or are not in a playlist/Music section like the iTunes store. It also checks if 'Enable access for assistive devices' is on, which should fix the problems some of the commenters had (I think).
tell application "System Events" to set isUIScriptingEnabled to UI elements enabled
if isUIScriptingEnabled = false then
	tell application "System Preferences"
		activate
		set current pane to pane "com.apple.preference.universalaccess"
		display dialog "Your system is not properly configured to run this script. Please select the 
		\"Enable access for assistive devices\" checkbox and trigger the script again to proceed."
		return
	end tell
end if

tell application "iTunes"
	activate
	if player state is playing then
		tell application "System Events" to keystroke "l" using command down
		set the_song to the current track
		play the_song
	end if
end tell

tell application "System Events"
	tell process "iTunes"
		repeat with the_button in every button of window 1
			set the_props to properties of the_button
			if description of the_props is "genius" then
				click the_button
				return
			end if
		end repeat
	end tell
end tell


[ Reply to This | # ]
Create an iTunes Genius playlist via keyboard shortcut
Authored by: ptujec on Jan 20, '11 02:33:56PM
Thanks! That actually helped! Thats what I am using:
-- iTunes - New Genius Playlist
--
-- source: http://www.macosxhints.com/article.php?story=20090805072808180
-- The script will use the currently selected song as the basis for your genius playlist. 
-- Checks if iTunes is hidden and keeps that way after script is done.
--
-- edited by ptujec
-- last edited 2011-01-20


tell application "System Events"
	try
		if visible of process "iTunes" is true then
			set okflag to true
		else
			set okflag to false
		end if
		
		
		tell application "iTunes"
			activate
			reveal current track
		end tell
	end try
	
	my _action()
	
	if okflag is false then
		set visible of process "iTunes" to false
	end if
	
end tell --

on _action()
	try
		tell application "System Events"
			
			tell process "iTunes"
				repeat with the_button in every button of window 1
					set the_props to properties of the_button
					if description of the_props is "genius" then
						click the_button
						-- return
					end if
				end repeat
			end tell
		end tell
	end try
end _action


[ Reply to This | # ]
Create an iTunes Genius playlist via keyboard shortcut
Authored by: ptujec on Jan 22, '11 07:58:51AM

Here is another one based on it:
http://ptujec.tumblr.com/post/2874324070/itunes-new-random-genius-playlist-script



[ Reply to This | # ]