Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erikssonfx

macrumors newbie
Original poster
Jun 24, 2012
2
0
Hello I need a script to rating the current track automatically. With the following script it isn't possible because theres an error by "★★★★★". Although this is actually the correct term. (I need to stretch the code with delays because the viewer should see the automatic-action)

Code:
tell application "iTunes"
	activate
end tell
delay 1
tell application "System Events"
	tell process "iTunes"
		key code 120 using control down
		delay 1
		tell menu bar 1
			click menu bar item "Ablage"
		end tell
	end tell
end tell
delay 1
tell application "System Events"
	tell process "iTunes"
		delay 1
		tell menu bar 1
			tell menu "Ablage"
				click menu item "Wertung"
			end tell
		end tell
	end tell
end tell
delay 1
tell application "System Events"
	tell process "iTunes"
		delay 1
		tell menu bar 1
			tell menu "Ablage"
				tell menu "Wertung"
					click menu item "★★★★★"
				end tell
			end tell
		end tell
	end tell
end tell
 
Code:
tell application "iTunes"
	if player state is playing then
		set myTrack to current track
		-- ★=20 so ★★★★★=100
		set rating of myTrack to 100
	end if
end tell

You can set the rating from the iTunes icon in the dock too.
 

Attachments

  • Picture 2.png
    Picture 2.png
    54.7 KB · Views: 75
Last edited:
thanks for the advice. I want to recreate natural actions, so i used the tell-orders to get to the rating item. then i closed all and faked it with your short code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.