Gui Script - Rating tracks in itunes

Discussion in 'Mac Programming' started by erikssonfx, Jun 24, 2012.

  1. macrumors newbie

    Joined:
    Jun 24, 2012
    #1
    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
     
  2. kryten2, Jun 24, 2012
    Last edited: Jun 24, 2012

    macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    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.
     

    Attached Files:

  3. thread starter macrumors newbie

    Joined:
    Jun 24, 2012
    #3
    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.
     

Share This Page