Spotify Ad Blocker

Post your working scripts, libraries and tools for AHK v1.1 and older
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Spotify Ad Blocker

14 Apr 2018, 03:16

Code: Select all

#singleinstance force

Spotify:
Tooltip
WinGet _windows, List
Loop % _windows {
   _hwnd := _windows%A_Index%
   WinGet _process, ProcessName, ahk_id %_hwnd%
   WinGetTitle _title, ahk_id %_hwnd%
} until (_process == "Spotify.exe" && _title != "")
if (_process == "Spotify.exe") && !((_title ~= "-") || (_title ~= "(?i)^Spotify(\sFree)?$") || (_title = "drag")) {
   Tooltip % "1"
   Process Close, %_process%
   Process WaitClose, %_process%, 60
   Tooltip % "2"
   _A := WinExist("A")
   Run %A_AppData%\Spotify\Spotify.exe --minimized
   WinWait Spotify
   Tooltip % "3"
   WinWait Spotify Free
   WinActivate ahk_id %_A%
   Sleep 1000
   Send {Media_Next}
   Tooltip % "Spotify Ad Blocked!"
   Sleep 10000
}
Sleep 10
Goto Spotify
return
This code blocks ads on Spotify. It is provided as-is and confirmed working as of 2020-03-10.

Explanation - The way this script works is that it checks to see if there are any windows that are associated with the Spotify.exe process. If found, then it checks to see if the name has a hyphen, as in Artist - Song Name. Generally Advertisements don't have a hyphen in them. It then closes Spotify and restarts it!
Last edited by iseahound on 10 Mar 2020, 16:25, edited 6 times in total.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: A gift for you all

14 Apr 2018, 03:51

why not swap the post's title with its contents
Blockefella Records

Re: A gift for you all

14 Apr 2018, 05:49

Music to my ears!

Thank you
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: A gift for you all

14 Apr 2018, 09:58

I have Spotify Premium :(
Recommends AHK Studio
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: Spotify Ad Blocker

04 Jun 2018, 02:36

small update
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: Spotify Ad Blocker

03 Oct 2019, 21:22

Another update, with code explanation!
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: Spotify Ad Blocker

04 Oct 2019, 23:05

Bugfix: Dragging a song to a playlist caused the script to trigger.
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: Spotify Ad Blocker

06 Oct 2019, 21:16

Sounds like something a poor person would say. I prefer to allocate my funds towards content creators. If a content creator receives $10/month from at least 500 people, they can work on their content full-time, which is much more productive and valuable to individuals and society.
xeroexi
Posts: 1
Joined: 15 Dec 2020, 22:14

Re: Spotify Ad Blocker

15 Dec 2020, 22:16

hi this works really well thx for this is there anyway you can make one without the 1,2,3 or tooltips i think its called in the code. so that it just skips the ad.
edit** also sometimes if spotify gets an ad and the title of spotify changes to "spotify free" the add will play and not get skipped however the ad after that will skip but will not autoplay after spotify gets restarted

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 144 guests