Created
May 26, 2016 14:07
-
-
Save craigmjohnston/c8a46bb8b96a2a334868d3f72c741fda to your computer and use it in GitHub Desktop.
AutoHotkey script for media controls, including the SpotifySaveToMusic script snippet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Spotify "Save to Music" | |
Based on: http://superuser.com/a/879589 | |
Fires on Ctrl+Shift+L, but obviously you can change that to whatever you want. | |
*/ | |
^+l:: | |
spotify = ahk_class SpotifyMainWindow | |
IfWinExist, %spotify% | |
{ | |
;Store active window and mouse position. | |
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, 68, spotifyHeight - (isMaximised = 1 ? 105 : 83), 1, 0 | |
PixelGetColor, pixelColor, 68+174, spotifyHeight - (isMaximised = 1 ? 105 : 83) | |
if (pixelColor != 0x333333) { | |
;Move down to 'Add to your music' and hit enter | |
loop, 5 { | |
Send {Down down}{Down up} | |
} | |
Send {Enter down}{Enter up} | |
} else { | |
;Already added, so close context menu | |
Send {Escape down}{Escape up} | |
} | |
;Restore original window and mouse position. | |
WinActivate ahk_id %winID% | |
MouseMove %x%, %y% | |
} | |
Return | |
; Media buttons | |
^+Left::Send {Media_Prev} | |
^+Right::Send {Media_Next} | |
^+Enter::Send {Media_Play_Pause} | |
^+=::Send {Volume_Up} | |
^+-::Send {Volume_Down} | |
^+0::Send {Volume_Mute} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment