I tried this in an on clicked handler to set the rating of the current song to the contents of my level indicator. This is what I have, but sometimes when you click, it only gives you half values and others it gives you a full star. Its just really inconsistent.
tell window "main"
set therate to (contents of control "ri") * 20
end tell
tell application "iTunes"
set cur_track to the current track
set the rating of cur_track to therate
end tell
Ok, so I managed to do that, with longer code, but now I have another problem. I made a method that gets gets the rating of the current track and another for setting the rating. So now I cannot set the rating because they are conflicting.
Here are my two methods I use.
get stars method:
on getstars()
set starnum to 0 as integer
tell application "iTunes"
set cur_track to the current track
set cur_rate to the rating of cur_track
if cur_rate = 0 and cur_rate < 20 then
set starnum to 0
else if cur_rate > 19 and cur_rate < 40 then
set starnum to 1
else if cur_rate > 39 and cur_rate < 60 then
set starnum to 2
else if cur_rate > 59 and cur_rate < 80 then
set starnum to 3
else if cur_rate > 79 and cur_rate < 100 then
set starnum to 4
else if cur_rate = 100 then
set starnum to 5
end if
end tell
tell window "main"
set contents of control "ri" to starnum
end tell
end getstars
and the set stars method:
on setstars()
tell window "main"
set therate to contents of control "ri"
end tell
tell application "iTunes"
set cur_track to the current track
if therate = 0 then
set the rating of cur_track to "0" as integer
else if therate = 1 then
set the rating of cur_track to "20" as integer
else if therate = 2 then
set the rating of cur_track to "40" as integer
else if therate = 3 then
set the rating of cur_track to "60" as integer
else if therate = 4 then
set the rating of cur_track to "80" as integer
else if therate = 5 then
set the rating of cur_track to "100" as integer
end if
end tell
end setstars
on getstars()
tell application "iTunes"
set starnum to (rating of current track) div 20
end tell
set contents of control "ri" of window "main" to starnum
end getstars
on setstars()
set therate to ((content of control "ri" of window "main") as integer) * 20
tell application "iTunes"
set rating of current track to therate
end tell
end setstars