28

After March 2015 upgrade of Spotify the below hotkey no longer works to get next song in Spotify:

; Spotify next track
<^>!p::
DetectHiddenWindows, On 
ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off 
Return 

The SpotifyMainWindow" appears to be the same when checking with spy, and Ctrl-Right also still works for next song in Spotify, but the hotkey don't.

How to make a hotkey for next song in the upgraded Spotify?

EquipDev
  • 3,807
  • 8
  • 27
  • 53
  • Same issue here since the update. Are you sure that SpotifyMainWindow is still correct? – Tony Trozzo Mar 10 '15 at 15:49
  • 1
    This is a serious issue. With the latest update, Spotify blocks all sent input when NOT in foreground. Same goes for sending `{space}`. I wasn't able to solve it with send/postmsg: `sendmessage, 256, 32, 3735553,Chrome_RenderWidgetHostHWND1, ahk_class SpotifyMainWindow`,`sendmessage, 257, 32, 3735553,Chrome_RenderWidgetHostHWND1, ahk_class SpotifyMainWindow` This successfully sends `{space}` down and releases it afterwards. But, it ALSO only works when Spotify is ACTIVE. This is bad because postMessage is usually the last hope for problems like that. Hope this will help finding the solution – phil294 Mar 10 '15 at 15:55
  • 3
    I'm a developer at Spotify. We know that there are some regressions in the new client, especially regarding remote control. I'll ask my colleagues about this issue, also can you please confirm that this problem is on Windows? – Nik Reiman Mar 10 '15 at 16:07
  • OS is Windows 7 64-bit fully updated, Spotify version is 1.0.1.1060, and AutoHotkey is version 1.0.48.05. I would really appreciate if you can pull some strings to make this work again :-) – EquipDev Mar 10 '15 at 16:10
  • 1
    @EquipDev we've looked into it and fixed the problem! (Turns out it was an easy fix). It will be shipped in the next update of the desktop client. – Nik Reiman Mar 11 '15 at 12:48
  • @NikReiman: Just updated to Windows client version 1.0.2.6, but the AHK code from the question does still not work for next track. However, I don't know the latency through the Spotify release procedure, so maybe this update does not contain the fix, – EquipDev Mar 20 '15 at 15:12
  • 1
    Just downloaded an update to version 1.0.2.6.g9977a14b and my hotkeys also don't work still. Please fix :) – Martin Mar 21 '15 at 14:16
  • @NikReiman: has the fix been released yet? I'm on the latest version on Windows and it looks like, so long as Spotify is full screen (can be behind another window but not minimised), half of my hotkeys now work (next / previous track and volume up / down), however pausing / playing doesn't work. It would be preferable that all hotkeys function even with Spotify minimised. – ClarkeyBoy Apr 09 '15 at 09:45
  • @NikReiman: Just updated to 1.0.3.101.gbfa97dfe and playing/pausing using `ControlSend, ahk_parent, {SPACE}, Spotify` still doesn't work regardless of whether or not the window is minimised. – jimmyjudas Apr 16 '15 at 15:45
  • I've mentioned these issues to our Windows devs, just FYI – Nik Reiman Apr 17 '15 at 09:14
  • Just upgraded to 1.0.4.90.g0b6df40b. Still broken for me, even with the solutions below. – Martin Apr 24 '15 at 16:37
  • On 1.0.6.80.g2a801a53, and everything except play/pause works. – Martin May 31 '15 at 15:54
  • For that it's worth, it's broken with ControlSend. I am having to resort to bringing Spotify forward and a regular Send, as if a real keyboard was doing it. – Martin May 31 '15 at 16:02

5 Answers5

47

I managed to make it work using multimedia keycodes. Here's my script:

; "CTRL + LEFT"  for previous 
^Left::Media_Prev


; "CTRL + RIGHT"  for next 
^Right::Media_Next


; "CTRL + SPACE"  for pause
^Space::Media_Play_Pause

It's working like a charm now.

  • Great, that did the trick, and is a generic solution. This is better than finding the Spotify windows and sending keystrokes to that, now that nice Spotify developers have hooked Spotify into the generic media keys. – EquipDev Mar 12 '15 at 06:05
  • For what it's worth, this doesn't seem to work for me. I tried it as both `^{Right::Media_Next}` and `^Right::Media_Next`. – Martin Mar 15 '15 at 18:46
  • The only two other lines I have before those are: `DetectHiddenWindows, On` `SetTitleMatchMode 2` Maybe those do the trick for you... – Manuel Ruiz de Quintanilla Mar 16 '15 at 19:34
  • If anyone knows how to get the track info after update, please answer to my question here http://stackoverflow.com/questions/29821881/fetch-the-current-track-info-from-spotify-app-after-march-2015-update – otterb Apr 23 '15 at 11:25
  • any way to hide the tooltip that shows up? (Windows 10) –  Nov 19 '16 at 19:49
  • This conflicted with the "CTRL + WIN + " default shortcut for switching desktops on Windows 10 but it works great after tweaking to get around that. – airdas Jan 24 '19 at 14:40
6

For Windows 8 Users, I modified the previous script to one that will work for your OS! Will change to Previous song, Pause/Play, Next song

; "CTRL + LEFT"  for previous 
^Left::Send {Media_Prev}


; "CTRL + RIGHT"  for next 
^Right::Send {Media_Next}


; "CTRL + SPACE"  for pause
^Space::Media_Play_Pause
4

A work around in the mean time is to bring the Spotify window to the front, send it a space and then minimise it again.

You may want to stop it minimising according to your own preference

Re-edit - got it working for skipping tracks as well, it's a bit hacky and may not work if you have UAC enabled (according to the docs) , YMMV. Works for me though

ScrollLock::
{
 DetectHiddenWindows, On
 WinActivate, ahk_class  SpotifyMainWindow
 SendInput, , ^{Right}, ahk_class SpotifyMainWindow
 Sleep, 100
 ControlSend, , {Space}, ahk_class  SpotifyMainWindow
 DetectHiddenWindows, Off
 WinMinimize, ahk_class  SpotifyMainWindow
 return
}


PrintScreen::
{
 DetectHiddenWindows, On
 WinActivate, ahk_class  SpotifyMainWindow
 SendInput, , ^{Left}, ahk_class SpotifyMainWindow
 Sleep, 100
 ControlSend, , {Space}, ahk_class  SpotifyMainWindow
 DetectHiddenWindows, Off
 WinMinimize, ahk_class  SpotifyMainWindow
 return
}

Pause::
{
 DetectHiddenWindows, On
 WinActivate, ahk_class  SpotifyMainWindow
 ControlSend, , {Space}, ahk_class  SpotifyMainWindow
 DetectHiddenWindows, Off
 WinMinimize, ahk_class  SpotifyMainWindow
 return
}
Wil
  • 329
  • 3
  • 12
  • Thanks, might be a step in the right direction, but as you noted then skip does not work. I was able to get skip to work in maybe 1 of 10. – EquipDev Mar 11 '15 at 10:16
  • Thanks for the additional update, which made the hack work. However, based on @NikReiman answer with general Spotify update, I expect to accept that answer once I have confirmed it works. But your work around is appreciated for use in the mean time. – EquipDev Mar 11 '15 at 15:15
1

Just tested this with latest spotify and Windows 10

; "CTRL + ALT + UP" for volume up
$^!Up::Volume_Up

; "CTRL + ALT + DOWN" for volume down
$^!Down::Volume_Down

; "CTRL + ALT + LEFT" for previous 
^!Left::Media_Prev

; "CTRL + ALT + RIGHT" for next 
^!Right::Media_Next

; "CTRL + ALT + SPACE" for pause
^!Space::Media_Play_Pause
Frank Fu
  • 2,842
  • 2
  • 24
  • 34
  • 1
    This is the same solution as above. (wtf?) – phil294 Jan 20 '16 at 00:13
  • You have a point, but I included 3 same features (previous, next pause) with different ways to achieve those features (adding an alt key). I think it helps people with reducing the amount of keyboard shortcut conflicts (e.g. When i'm using Visual Studio or Sublime Text). I also added 2 extra features such as volume up and down which may be important to some people – Frank Fu Jan 21 '16 at 04:12
1

I saw this working but not for the key I wanted

^Space::Media_Play_Pause

and decided to see if this would work

Numpad4::^Media_Prev
Numpad5::^Media_Next
Numpad6::^Media_Play_Pause

and it does! yay. I guess it works for whatever keys you want and not just the space key.