Spotify Pause Macro Stopped Working

This macro has been working for a while now, but recently it stopped. I'm hoping someone here can shed some light on what I'm missing.

Here's the basic set up:

The script path is /Users/name/Dropbox/bin/spotify-pause-start.scpt. Running this script from the command line works perfectly. Clicking the Try button produces nothing. The script doesn't return anything, so toggling the results options predictably has no effect.

Any advice or insight into debugging this would be most appreciated.


A script executed from Keyboard Maestro varies in many ways from a script executed in the Terminal - most importantly in the PATH variable.

See my comments on Detecting the locale for more details.

That make sense, but nothing in my AppleScript is dependent on the path or environment variables. Here’s the AppleScript I’m trying to execute:

tell application "System Events"
    set MyList to (name of every process)
end tell
if (MyList contains "Spotify") is true then
    tell application "Spotify" to playpause
end if

Hey There,

You don't tell us if the script itself works when run from the Applescript Editor.

I've rewritten it a trifle, and so far it's working fine for me using F1 for my keyboard shortcut.

tell application "System Events"
   set quit delay to 0
   set spotifyIsRunning to (name of every process) contains "Spotify"
end tell
if spotifyIsRunning then tell application "Spotify" to playpause

There is nothing wrong with using System Events, but you need to be aware the system may quit it without your consent. When that happens there can be occasions where its activation delay can be rather long instead of the usual fraction of a second.

If you use it frequently in your scripts it's a good idea to set the quit delay to 0 (zero) and thus turn it off.

As usual AppleScripts run a little bit faster when run as a script-file instead of a text-script.


Yes, the script works fine when run from the Applescript Editor.

I don’t usually run Spotify from my system at home, so I set it up to test it. My script runs fine within Keyboard Maestro, so there must be something weird happening on my system at the office. It’s definitely not a hot key conflict. I’ll test it from the Applescript Editor on Monday and update accordingly. If it doesn’t work, I’ll try your script and see if that makes a difference.

And thank you for the script. That’s above and beyond.

I’ll let you know on Monday.

Thanks again.

I’m not sure what the issue was/is, but restarting Keyboard Maestro fixed the problem.

Sorry for the bother and thanks for the assist!