How to STOP music (if playing) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Elenkhos
Posts: 31
Joined: 27 Feb 2018, 09:08

How to STOP music (if playing)

03 May 2018, 15:55

I would like to stop Spotify from playing when I start my TV to watch a video but the problem is that {Media_Stop} doesn’t work. If the music is not playing and I use {Media_Play_Pause} command the music starts when it should stop.

Another way would be to recognise if the music is playing and send the pause command only then but I guess that would be too complicated if even possible.

I have run out of ideas how to achieve something so simple. Help would be appreciated.
spoko
Posts: 3
Joined: 30 May 2017, 10:55

Re: How to STOP music (if playing)

23 Apr 2019, 10:19

Did you ever find a solution for this? I'd like the same thing.
Elenkhos
Posts: 31
Joined: 27 Feb 2018, 09:08

Re: How to STOP music (if playing)  Topic is solved

23 Apr 2019, 10:30

In fact, I did! I found a program named Toastify which had this functionality and spoke with its developer and found a way to send media commands straight to Spotify. It requires that you assign the right Spotify window id to a variable with this code (run in auto-execute section):

Code: Select all

DetectHiddenWindows, On
If WinExist("ahk_exe Spotify.exe ahk_class Chrome_WidgetWin_0")
{
	SetTitleMatchMode, RegEx
	WinGet, SpotifyId, ID, .+ ahk_exe Spotify\.exe ahk_class Chrome_WidgetWin_0
	SetTitleMatchMode, 1
}
DetectHiddenWindows, Off
Return
Then use this command to stop the music:

Code: Select all

DetectHiddenWindows, On
If WinExist("ahk_id " SpotifyId)
	PostMessage, 0x0319,, 0x002F0000,, ahk_id %SpotifyId%
DetectHiddenWindows, Off
Return
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: How to STOP music (if playing)

23 Apr 2019, 14:46

I'd like to post this as an alternative. It uses the Spotify API, which affects your entire Spotify account. Meaning, it can pause/play/change music/volume/etc. on any device that your account is currently streaming to.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
Elenkhos
Posts: 31
Joined: 27 Feb 2018, 09:08

Re: How to STOP music (if playing)

23 Apr 2019, 15:52

Masonjar13 wrote:
23 Apr 2019, 14:46
I'd like to post this as an alternative. It uses the Spotify API, which affects your entire Spotify account. Meaning, it can pause/play/change music/volume/etc. on any device that your account is currently streaming to.
Thanks, that seems really interesting! I will test it out.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Frogrammer, gongnl and 285 guests