I’ve been using Spotify for a few months now. However, I’ve been thinking for a while it would be useful to have some keyboard shortcuts to manage Spotify without having to open the UI. I’ve taken some of the existing scripts on the AutoHotkey forums and made some alterations to come up with a small script to implement the requirements below. If you’re an AutoHotkey newbie I’ve also documented what each command in the script is doing.
Requirements for the script
Whilst listening to a list of tracks that a search returned I’d like to be able to move back and forward between tracks without opening the Spotify UI.
When a song comes on that I really like I’d like to be able to hit a hot key to save this track to a playlist that keeps my favourite tracks of all time. I’d also like to carry on with my work and not have to open the Spotify UI.
Solution
To fulfil these requirements the script I’ve put together does the following:
When the key combination Shift + Alt + right is pressed AutoHotkey maps this to Ctrl + right arrow and sends this directly to the Spotify window using the ControlSend command. The DetectHiddenWindows command is used to allow AutoHotkey to see Spotify if it is minimized to the system tray.
+!Right::
{
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return
}
To move to the previous track the same process is followed, but using Shift + Alt + left.
+!Left::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return
Moving back and forward between tracks are very simple operations because Spotify has keyboard shortcuts for these. However, Spotify doesn’t have a keyboard shortcut for adding the playing track to a playlist. To achieve this requires more effort. If you wanted to do this manually you’d take the following steps:
- Open the Spotify window
- Right click on the track graphic in the left corner of the Spotify window. Right clicking the track graphic will open the menu options for this track.
- Move down to “Save to”, in the menu, and then hit enter to add to the playlist you require.
- Minimise Spotify and carry on with your work.
All that’s required now is to automate these steps. One limitation of the script is that it will always save to the first playlist in the dropdown. So it’s important to drag the playlist you’d like to use to the top of the playlists section. In the below example the tracks would be saved to the Rob playlist as that’s the first playlist.

The script maps Alt + Shift + Up to add the playing track to the playlist. And here’s the commands that make up the script. I’ve added a comment above each command.
^!Up::
{
;Tells the mouse to move instantly to the correct position.
SetDefaultMouseSpeed, 0
;Set coordinates to be relative to the screen.
CoordMode, Mouse, Screen
;Gets the current position of the mouse.
MouseGetPos, original_mouse_x, original_mouse_y
;Gets the current active window.
WinGetActiveTitle, original_window_title
;Tells AutoHotkey to detect hidden windows.
DetectHiddenWindows, On
;Checks it Spotify is running.
IfWinExist, ahk_class SpotifyMainWindow
{
;If Spotify is in the system tray then restore it.
WinRestore, ahk_class SpotifyMainWindow
;Activate the Spotify window.
WinWaitActive, ahk_class SpotifyMainWindow
;Get the position of the Spotify window.
WinGetPos, X, Y, Width, Height, ahk_class SpotifyMainWindow
;Click the right mouse button offset to be in the middle of the track image.
MouseClick, right, X+50, Y+Height-70
;Sleep to give the command chance to execute.
Sleep, 200
;Send “s” to move to “Save to”. Send “Right” to move to the first playlist. Send “enter” to confirm adding to the playlist.
ControlSend, ahk_parent, {s}{RIGHT}{ENTER}, ahk_class SpotifyMainWindow
;Sleep to give the command chance to execute.
Sleep, 200
;Minimise the Spotify window.
WinMinimize, ahk_class SpotifyMainWindow
;Move the mouse back to the original position.
MouseMove, original_mouse_x, original_mouse_y
;Activate the window you were originally working in.
WinActivate, %original_window_title%
}
;Tell AutoHotkey to stop detecting hidden windows
DetectHiddenWindows, Off
return
}
The full script can be downloaded from here.
For more Developer productivity tips you can visit my other blog - The Home Row