Skip to content

Instantly share code, notes, and snippets.

@dogancelik
Last active July 16, 2021 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogancelik/a488a5878c1e555b0ad0290b557ea65d to your computer and use it in GitHub Desktop.
Save dogancelik/a488a5878c1e555b0ad0290b557ea65d to your computer and use it in GitHub Desktop.
Like or unlike currently playing song in Spotify #Windows #AutoHotkey

Modified GollyJer's script to allow to save or unsave currently playing Spotify song.

Save SpotifyHeartOn as SpotifyHeartOn.png

Save SpotifyHeartOff as SpotifyHeartOff.png

Put the images in same folder as the script.

SearchIcon(IconPath) {
ImageSearch FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %IconPath%
if (ErrorLevel = 0) {
global RealFoundX := FoundX
global RealFoundY := FoundY
} else if (ErrorLevel = 2) {
; MsgBox, , , "Maybe image path is wrong.", 1
} else if (ErrorLevel = 1) {
; MsgBox, , , "Can't find heart icon.", 1
}
}
WinTitle := "ahk_exe spotify.exe"
IconOff := A_ScriptDir . "\SpotifyHeartOff.png"
IconOn := A_ScriptDir . "\SpotifyHeartOn.png"
if WinExist(WinTitle) {
MouseGetPos OutputX, OutputY, OutputWin
WinActivate %WinTitle%
WinWaitActive %WinTitle%
SearchIcon(IconOff)
SearchIcon(IconOn)
if (RealFoundX > 0 and RealFoundY > 0)
Click %RealFoundX%, %RealFoundY%
WinActivate ahk_id %OutputWin%
MouseMove %OutputX%, %OutputY%
}
@Zivers88
Copy link

Hi! How can I use it? It is Not working at all

@dogancelik
Copy link
Author

@Zivers88, yeah Spotify changed their heart icon, so I updated them, you can download the new images above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment