Any Spotify tweaks with keyboard shortcut to 'star' tracks?

20

4

I'm a premium subscriber of Spotify and an obsessive productivity geek.

One thing that really annoys me is that there isn't a keyboard shortcut to 'star' a track (I.e add a track to favourites). I like to leave Spotify radio on while I'm working and every now and again I have to tab over and right click on the track then select 'Star' whenever I hear a song I really like.

Are there any Spotify tweaks/plugins out there that will allow me to 'star' tracks with a keyboard shortcut?

Eddy

Posted 2011-08-17T17:12:28.997

Reputation: 2 897

Are ou using Windows Media player? – Diogo – 2011-08-17T17:26:45.790

Nope, just Spotify – Eddy – 2011-08-19T11:46:14.777

Answers

3

Sure, use AutoHotkey!

Once you've got it installed, put this in your AutoHotkey.ahk file:

#*::
WinWait, Spotify, 
IfWinNotActive, Spotify, , WinActivate, Spotify, 
WinWaitActive, Spotify, 
MouseClick, left,  79,  90
Sleep, 100
MouseClick, left,  256,  152
Sleep, 100
return

This adds a Win+Asterisk hotkey that'll star the track that's playing.

You may also be interested in other Spotify shortcuts for AutoHotkey.

seisyll

Posted 2011-08-17T17:12:28.997

Reputation: 171

1problem is that spotify also has same location when clicking to UNSTAR a track. so got to becareful incase you unstar a starred track using ahk method – ms. mann – 2012-08-10T01:51:22.407

2

I tried the other Autohotkey shortcut and it didn't work for me (just switched to spotify and clicked in two dead spots). I devised the following, which works so long as you have "Large Now Playing Artwork" selected:

CoordMode, Mouse, Relative
;star currently playing
+^l::
SpotifyWinHeight = 1050 ;set to 1080 - 30 for small taskbar size, just in case WinGetPos doesn't work for some reason
WinGetActiveTitle, CurWindow
WinActivate Spotify
WinWaitActive Spotify
WinGetPos,  ,  ,  , SpotifyWinHeight, Spotify
;          X  Y  W  H, we don't care about anything but height
RightClickTarget := SpotifyWinHeight - 250
ContextMenuTarget := RightClickTarget + 110
MouseMove, 100, %RightClickTarget%
Click Right
Sleep, 50
MouseMove, 180, %ContextMenuTarget%
Sleep, 50
Click
WinActivate %CurWindow%
return

It does the following:

  • Stores currently active window
  • Activates Spotify
  • Calculates the offsets for clicking on the album artwork relative to spotify window
  • Stars what's currently playing (via right-click artwork, left click Star)
  • Restores whatever window was active before all of this

It's not perfect (will probably not be happy if for some reason you have spotify hanging mostly off your screen to the right), but gets the job done in most cases.

RCIX

Posted 2011-08-17T17:12:28.997

Reputation: 5 415

This is great! Thanks. An improvement would be to read the last context menu item to see if it reads Unstar, and if so don't click it. If I get to it I'll come back and post. – GollyJer – 2012-12-20T20:22:06.913

2

Starred is no longer a thing.

Go here for the updated Q&A.


Old answer below here...

Here's another AutoHotkey solution. There are liberal comments. Also, the AutoHotkey documentation and forums are great places to learn if desired.

Pressing Control+Shift+* will star the active song.
A key feature of this script is that it checks to see if the song is already starred and leaves it alone if so.

^+*::
spotify = ahk_class SpotifyMainWindow
IfWinExist, %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.
    Send {Down}{Down}{Down}{Down}{Down}{Enter}
} Else {
    ;Just close the context menu.
    Send {Escape}
}

;Restore original window and mouse position.
WinActivate ahk_id %winID%
MouseMove %x%, %y%
}

Return

;Conext 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
}

GollyJer

Posted 2011-08-17T17:12:28.997

Reputation: 4 896

This no longer works. See my solution. – tig – 2015-02-18T18:15:08.120

0

Spotify no longer has the "star", and I can't seem to retrieve the contents of the context menu any more either, so this method looks at a pixel color in the context menu and uses the arrow keys to select. Works if maximized, minimized, and if album art is large or small.

^+*::
{
    spotify = ahk_class SpotifyMainWindow
    IfWinExist, %spotify% 
    {
        ;Store active window and mouse position.
        WinGet, MMX, MinMax, %spotify%
        WinGetActiveTitle, activeWindow
        MouseGetPos x, y, winID

        ;Activate Spotify.
        WinActivate %spotify%
        WinWaitActive %spotify%

        ;Get maximised status
        WinGet, isMaximised, MinMax

        ;Clear any context menus
        Send {Escape down}{Escape up}

        ;Right click near the song title in the "Now Playing" box.
        WinGetPos,  ,  ,  , spotifyHeight, %spotify%
        MouseClick, Right, 44, spotifyHeight - (isMaximised = 1 ? 75 : 66), 1, 0
        sleep 200
        MouseMove 10,0, ,R
        sleep 200

        ; Determine if the song is already added to your library or not
        ; Look at left edge of the 'S' in Save to Your Library
        ; or the 'R' in Remove from Your Library
        ; 0x282828 is the background color of the menu
        ; if the background color is not present then the song is not in your library
        PixelGetColor, pixelColor, 91, spotifyHeight - (isMaximised = 1 ? 129 : 119)
        if (pixelColor = 0x282828) {
            ;Move up to 'Save to Your Library' and hit enter
            loop, 1 {
                Send {Up down}
                sleep 50
                Send {Up up}
                sleep 50
            }
            Send {Enter down}
            sleep 50
            Send {Enter up}
            sleep 50
        } else {
            ; Already added, so close context menu
            Send {Escape down}
            sleep 50
            Send {Escape up}
            Sleep 50
        }

        ;Restore original window and mouse position.
        IfEqual MMX, -1, WinMinimize, %spotify%
        WinActivate ahk_id %winID%
        MouseMove %x%, %y%

    }
    Return
}

Craig

Posted 2011-08-17T17:12:28.997

Reputation: 1

0

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
}

Jordan

Posted 2011-08-17T17:12:28.997

Reputation: 177

0

You could also try my Spotify App, Twinkle, which is a platform and GUI layout independent solution for staring Spotify songs with a single click.

Erik R. Yverling

Posted 2011-08-17T17:12:28.997

Reputation: 1

0

The solutions that depend on there being a "Star" command no longer work... there is no longer a Star command, but "Starred" is a folder items can be added to. This script does this.

; Spotify "Star Song"
^+*::
spotify = ahk_class SpotifyMainWindow
IfWinExist, %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

;Open Add To... sub-menu
Send {A}

;The "Starred" command is the 2nd menu item. If the song is Starred it will be disabled.
Send {Down}{Enter}

;Restore original window and mouse position.
WinActivate ahk_id %winID%
MouseMove %x%, %y%
}

Return

tig

Posted 2011-08-17T17:12:28.997

Reputation: 101