-
-
Save craigmjohnston/67233423b32b8fd12bec98c6916d5698 to your computer and use it in GitHub Desktop.
/* | |
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 |
(sorry for double post)
That one works
!A::
spotify = ahk_class SpotifyMainWindow
IfWinExist, %spotify%
{
;Store active window and mouse position.
WinGetActiveTitle, activeWindow
MouseGetPos x, y, winID
;Activate Spotify.
WinActivate %spotify%
WinWaitActive %spotify%
;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
WinGetPos, X, Y, Width, Height, ahk_class SpotifyMainWindow
MouseClick, left, X+265, Y+Height-105
WinActivate ahk_id %winID%
MouseMove %x%, %y%
}
Return
I took it from here (https://autohotkey.com/board/topic/94218-spotify-global-hotkeys-volume-control-skip-songs-current-song-to-clipboard-star-songs-without-opening-spotify/), corrected positions and fused it with yours but I can't figure out how to make your condition work (not a coder or anything lol), so it always clicks on the "plus" without verification. My English is weird, sorry, I am French.
Hello, thank you for your script but it doesn't work in Spotify's last version. The dialog opens just well but it doesn't do anything after that…