I think Spotify is a great way to get lots of music and the people at Spotify obviously need their money, however, there are times when you just don't wanna hear their ads.
What this script does is simple, it mutes the volume when there is an an on, and unmutes it when the ad is finished.
NOTE: For this to function on Vista Autohotkey.exe needs to be run in XP-compability mode. It also only works when Spotify is the active window
Comments and suggestions are more than welcome.
Code:
#Persistent
SetTimer, AdOrNot, 1000
return
AdOrNot:
{
IfWinActive, ahk_class SpotifyMainWindow
{
WinGetPos,,,Width ,Height , A
X := Width-221
X2 := Width-251
Y := Height-19
PixelGetColor, color, %X%, %Y% ;Checks a pixel where the progress bar is visible when music is playin
PixelGetColor, color2, %X2%, %Y% ;Same thing 30 pixels left, to avoid hitting the slider that shows the position in the song
If (color=0x3F3F3F OR color=0x2E2E2E OR color2=0x3F3F3F OR color2=0x2E2E2E) ;Checks if the pixels matches the progress bar
{
SoundGet, master_mute, , mute
If master_mute = On
SoundSet, +1, , mute
}
Else
{
SoundGet, master_mute, , mute
If master_mute = Off
{
SoundSet, +1, , mute
Sleep, 300
Send, {Media_Play_Pause} ;Spotify pauses ads on Mute, therefore we need to get it playing again
}
}
}
}
return
Any ideas on how this could be done when Spotify is inactive/minimized?