Update this works with the latest version of Spotify 1.0.6.80.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;|---------------|
;|--[ SOURCES ]--|
;|---------------|
;Base Spotify Script from: http://www.autohotkey.com/board/topic/36239-spotify-global-hotkeys/
;Base Starring Script from: http://superuser.com/questions/324416/any-spotify-tweaks-with-keyboard-shortcut-to-star-tracks
;|------------------|
;|--[ SETTING UP ]--|
;|------------------|
DetectHiddenWindows, On ;Detect Spotify even if it's minimized
#IfWinExist ahk_class SpotifyMainWindow ;Only do the following if Spotify is running
spotify = ahk_class SpotifyMainWindow ;Set variable for Spotify Window Name
;|---------------|
;|--[ HOTKEYS ]--|
;|---------------|
; "F5" for previous
F5::Media_Prev
; "F6" for next
F6::Media_Next
; "F4" for pause
F4::Media_Play_Pause
; "F10" for track-name
F10::
{
WinGetTitle, spotify_playing, %spotify% ;Get the title of Spotify which contains the track-name
StringTrimLeft, trimmed_playing, spotify_playing, 0 ;Get rid of extra text and place into 'trimmed_playing'
StringReplace, replaced_playing, trimmed_playing, –, -, All ;Replace en dash with normal dash and place into 'replaced_playing'
clipboard = %replaced_playing% ;Copy the fixed text to clipboard
return
}
; "F3" for volume up
F3::
{
ControlSend, ahk_parent, ^{Up}, %spotify%
return
}
; "F2 for volume down
F2::
{
ControlSend, ahk_parent, ^{Down}, %spotify%
return
}
; "F8" for vote up in Radio
F8::
{
;Store active window
MouseGetPos, , , winID
;Left click near the song title in the "Now Playing" box.
WinGetPos, , , , spotifyHeight, %spotify%
clickX := 631
clickY := 556
ControlClick, x%clickX% y%clickY% , %spotify%, , Left, , NA
;Restore original window and mouse position.
WinActivate ahk_id %winID%
return
}
; "F7" for vote down in Radio
F7::
{
;Store active window
MouseGetPos, , , winID
;Left click near the song title in the "Now Playing" box.
WinGetPos, , , , spotifyHeight, %spotify%
clickX := 578
clickY := 577
ControlClick, x%clickX% y%clickY% , %spotify%, , Left, , NA
;Restore original window and mouse position.
WinActivate ahk_id %winID%
return
}
; Add track to Your Music
F9::
{
;Store active window
MouseGetPos, , , winID
;Left click near the song title in the "Now Playing" box.
WinGetPos, , , , spotifyHeight, %spotify%
clickX := 161
clickY := 924
ControlClick, x%clickX% y%clickY% , %spotify%, , Left, , NA
;Restore original window and mouse position.
WinActivate ahk_id %winID%
return
}
;|-----------------|
;|--[ FUNCTIONS ]--|
;|-----------------|
;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
}
Volume down/up now directly controls spotify.
I hope you can in corporate the f10 function in your app.
Dislike/like are f9 for songs and f7/f8 for radio both need adjusted to your position of spotify windows and mouse. But it works if set correctly, the user needs to be able to set those in your app tho.
If you do add those, make sure to add a note telling them that next track does not work in radio any more it is different now, you can but than you need to click it to make it work in your app it would be a pain and the script needs to be different. For me it is not needed in Radio.
I hope to see Like/dislike for songs to be supported otherwise I need to run a separate akh script.