Hotkey for next song in Spotify

删除回忆录丶 提交于 2019-11-29 21:27:27

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.

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

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
}

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!