How to stop Play Sound

I have a Play Sound action in a macro. (There's a surprise.) Sometimes, I don't want to play the entire sound. I would like to stop the sound and continue with the macro. But, I can't find any way to that. I tried: return, enter, space bar, and escape. I tried each as one press or two. I switched to Asynchronous (It was mentioned in the Wiki, but I don't know what it does.) and tried the same keys with no success. The Wiki had a brief and uninformative entry. The User Manual had nothing at all about Play Sound. It's a poor, orphaned action.

Is there any way out? Will I have to use Apple's Play Sound application? (Don't bother recommending iTunes. It is not a solution for me. It takes too long to load, and a song can't be stopped or iTunes can't be quit unless it's frontmost or you bring forth the Miniplayer, or you use third-party software.

Hey Greg,

I believe there's no way to stop playing a sound once you've started – at least with Keyboard Maestro.

But – you could create a mute-sound action that would pause for n seconds and then un-mute.


This is so bad. Mute would prevent beep and alert sounds. I don't know of any sound playing application on any platform that can't stop a long sound from finishing or have a keystroke that will cancel play. Off to Applescript and Play Sound. It's rather disconcerting how often I must use Applescript to build KM macros. Sometimes, I just use KM as a launcher for an Applescript app that is easier to write than an all-KM macro.

Greg T

Make a separate macro that has the "Cancel All Macros" action.

Triggering this new macro should cancel the other macro, which should stop the sound from playing.

It shouldn't cause any conflicts, unless you have other macros running in loops.


Canceling the macro will stop the sound.

1 Like

I'm confused. I'm running a macro that, halfway through, plays a long sound. I sometimes want to stop the sound and continue to run the macro. How can "Cancel All Macros" help? I need to cancel the sound and continue the macro or continue the macro with the sound still playing (a less desirable option). I could put a Prompt for User Response before Play Sound asking if I want to play the sound, but that would be annoying because most of the time I do.

Macros can be cancelled. Would it be possible to cancel a current action and continue its macro? I think that many users could make use of that. I know that the programming would be more difficult than for Cancel Macro, But, (a blatant appeal to egos), KM has excellent programmers..

I found that Play Sound (activated through KM or Applescript) doesn't work for me because the macro continues while the sound plays. I found a workaround. 1. Use Applescript to activate Play Sound and play your desired sound. [tell application "Play Sound" to play "Mac HD:Desktop Folder:My_Sound.aif" Existing variables included] 2. Follow that action with a Pause Until action that is triggered by the Escape key. The macro doesn't continue until you press Escape, which also stops the playing sound. The problem with this workaround is that if you let the sound play through, the macro doesn't automatically continue—you must press the Escape key. I tried to fix this by adding a condition to the Pause Until action, but I will be damned if I can find a way to enter a time interval. There is noting in the list related to time. (A serious deficiency, in my opinion.) I selected "The variable:" I started with "interval". It might work, if the units were listed. Seconds? Minutes? I put that aside and tried the more promising "Pause/Time". Same problem; no units. Search everything: manual, Wiki, forum and find nothing useful.

I created an easier solution for Applescript users. Write your macro and use an Applescript app to launch Play Sound and play Your_Sound. End the macro there. The Applescript stays open and checks the Play Sound state. You set up a loop to check the state every ## seconds. The state will be "playing" until the sound was cancelled (with the escape key) or finished. When that occurs, have Applescript launch a new macro that formerly was the part of the original macro after the sound play step. Isn't this fun?

My Applescript experience includes Play Sound (easy) and working with time and time intervals, mostly for custom alarms, (medium difficulty). It’s pitiful that I can write workaround code in Applescript faster than I can get info on time-related functions. in KM. Yes, I could write a macro to discover the time units of "interval" and "Pause/Time", but I shouldn't have to. It would not be hard to label the variables "Interval_min" or "Pause/Time_sec" or to have a pick-list for time units for each variable from seconds to days.

Greg T

The sound plays in the middle of the macro.

Not really. For one thing, you cannot currently even specify which instance of which macro you might want to cancel. But even assuming you could, you would have to specify which action you want to cancel, presuming that that action was currently running. Otherwise you would be canceling a single random action within a running macro, and that would be extremely fragile, error prone and dangerous.

There may be other solutions for your specific problem, but I can't think of any obvious Keyboard Maestro feature that would solve it. Maybe executing the Play Sound in a submacro and being able to explicitly cancel that submacro instance.

1 Like

So were we. When posting questions about complex (or longer) macros, it would help to see an example. Seeing the macro in question gives us context, and helps us understand your proposed methodology and goals better. Otherwise, we are shooting in the dark.

It seems like you have found a solution with your AppleScript approach—I hope it solves your issues.

I thought my question was clear. It was about the Play Sound action—the macro didn’t matter. How can the sound be turned off once the Play Sound action is triggered? You don't need an example to understand that uncomplicated question. If you want an example, toss Play Sound into any macro you wish, select a sound of more than 15 seconds, and test as much as you wish. It doesn't matter now, because the answer is that the sounds can't be stopped without quitting the KM Engine and not running the rest of the macro, which I find amazing and disturbing. It’s like having to quit QuickTime to stop the currently playing movie or song.

Greg T