Disable Keyboard and Mouse During Macro Execution

Is there a way to disable user input when macros are running?

Sometimes I have these huge macros running and I end up forgetting they are still performing actions or a worst case scenario last week my wife's cat decided sleeping on the keyboard of my macbook during a scheduled macro run.

I use alerts and notifications for reminding me when a macro is about to start or finish and use Pause Until Conditions Met using the IDLE function but it doesn't prevent me messing something during execution.

I understand that by disabling user input I could no longer panic cancel a macro if something goes wrong.

Any ideas?

Thank you all in advance.

How about just activating the Mac Screen Saver?
I just drag the mouse to the lower left corner to activate. Other options available.
You could probably do this in KM (just guessing)

I use lots of UI actions and if the screen is screen saving or the display is asleep they won’t work.

Thank you for the reply.

Wouldn't disabling input cause the same problem?

Are you sure that the Screen Saver will stop you apps?
You might find this helpful:
Keep Background Apps Running When You Lock Or Put Your Mac To Sleep

1 Like


Display a window (maybe use the Custom HTML Prompt?) that says not to touch anything, and keep it displayed (by putting it in a sub-macro and executing the macro asynchronously).

While you are screen saving, screen locked, or screen sleeping, you cannot do UI. You can still run macros (as long as your Mac is not asleep) with non-UI triggers like the Time trigger, and the macros can still do lots of things, but not UI stuff like clicks and keystrokes.

1 Like

Thanks for the clarification about the Screen Saver, Peter. That is very helpful.

Since Peter has confirmed that using the Screen Saver won't work, how about this: turn off your KB.

I use a usb wireless KB that has on on/off switch. Turn it off and the cat can't type. :grinning:

according to https://apple.stackexchange.com/questions/67133/how-to-disable-the-built-in-macbook-keyboard
you can call shell script to do this:

echo 'your admin password' | sudo -S kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

echo 'your admin password' | sudo -S kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

is this still not possible in 2020?
i have a macro that often get executed in a wrong way because of mouse interaction…



The problem I have is a kick off quite a short automation and then, without thinking, switch window/app. I’m not sure there’s a cure for that.

Hey @MartinPacker

Display a pop-up window or large text to remind you to keep your hands off:




I concur. Turn off or unplug your keyboard and mouse. It's the safest way and if you need to suddenly cancel the macro you can.
Regarding the screensaver you'll have to disable it if you are doing a lot of UI work.

I use a "Wait!" Macro just for that purpose, and it works well for me.


1 Like

Is this still not possible in 2024?

Hello @keyboard :wave:

No it’s still not possible in a native way - and I doubt that this will ever be ….

With Keyboard Maestro you have a wonderful tool at your hands to build you a solution that helps you staying away from your peripherals during long and complex macros.

There is the Macro suggested by @JMichaelTX above - but you could also build something completely different by yourself….

Another hint is can give you is - there are a lot of little nifty helper tools called as cleanup applications for your Peripherals … you could eventually use even those in your macros to lock up your keyboard trackpad and all other devices you use to control your Mac.

Greetings from Germany


I don't believe it is, because of the potential issues it could cause: As discussed above, if you had a runaway macro that disabled the mouse and keyboard, the only solution would be a hard reboot.

If the normal text window as shown earlier isn't enough to get your attention, you can use a custom HTML prompt in an asynchronously run sub-macro to display a more outlandish message:

The attached pair of macros contains a dummy "main" macro that just displays a random progress bar, and calls the sub-macro to display the warning.

__ xDemos- General for sharing Macros.kmmacros (6.8 KB)