I don't have the rep to put this in a comment to GollyJer's answer, but I noticed when trying to use that script that there was an issue with the {down} keystrokes that would somehow make it move the highlighted song in the playlist down, instead of moving down on the menu. I modified it to do a mouse click at the "Star" menu entry instead of using the keys, it seems to work quite well. I also edited it to minimize Spotify before it flips back to the window you were using if it was minimized to begin with.
^+*::
spotify = ahk_class SpotifyMainWindow
IfWinExist, %spotify%
{
WinGet, MMX, MinMax, %spotify%
;Store active window and mouse position.
WinGetActiveTitle, activeWindow
MouseGetPos x, y, winID
;Activate Spotify.
WinActivate %spotify%
WinWaitActive %spotify%
;Right click near the song title in the "Now Playing" box.
WinGetPos, , , , spotifyHeight, %spotify%
MouseClick, Right, 100, spotifyHeight - 70, 1, 0
;Get the contents of the context menu.
WinWait, ahk_class #32768
SendMessage, 0x1E1 ; MN_GETHMENU
allContextMenuInfo := ErrorLevel
;The "Star" command is the 5th menu item.
;If the song is Unstarred the text is Star, and vice versa. But sometimes some wierd characters are included.
;The only reliable way I found is to check if the first letter is S.
menuText_StarUnstar := GetContextMenuItemText(allContextMenuInfo, 5)
StringGetPos, positionOfS, menuText_StarUnstar, S
;If S is the first letter, star the song.
notStarred := (%positionOfS% = 0)
If notStarred {
;Arrow down to the Star menu item and press enter.
MouseClick, Left, 20, -120, 1, 0,, R
} Else {
;Just close the context menu.
Send {Escape}
}
;Restore original window and mouse position.
IfEqual MMX, -1, WinMinimize, %spotify%
WinActivate ahk_id %winID%
MouseMove %x%, %y%
}
Return
;Context menu helper function.
GetContextMenuItemText(hMenu, nPos)
{
length := DllCall("GetMenuString"
, "UInt", hMenu
, "UInt", nPos
, "UInt", 0 ; NULL
, "Int", 0 ; Get length
, "UInt", 0x0400) ; MF_BYPOSITION
VarSetCapacity(lpString, length + 1)
length := DllCall("GetMenuString"
, "UInt", hMenu
, "UInt", nPos
, "Str", lpString
, "Int", length + 1
, "UInt", 0x0400)
return lpString
}
Are ou using Windows Media player? – Diogo – 2011-08-17T17:26:45.790
Nope, just Spotify – Eddy – 2011-08-19T11:46:14.777