Lock mouse while macro

Hello! im trying to lock my mouse while he moving and do macros, so i cant move it mistakably. anyone knows how?

Hi @avinaf - welcome to the KM forum.

When this question was asked previously, the answer was “no”.


As @tiffle says, I don't think that can be done.

In my case I make use of Keyboard Maestro's Progress Bar to warn me not to move the mouse while certain Macros are running or starting up. Here is an example. The example has a pause of 10 seconds that is a placeholder for your actual Macro. It also puts the warning right in the centre of the screen so I can't miss it!

To explain the mechanics of the Progress Bar - putting in a value of -1 causes the Progress Bar to pulse and a Value of 100 closes the Progress Bar. Other values would put the Progress Bar at different points. 50 would put it half way, 99 would put it pretty much full.

So, instead of having the Progress Bar pulsing, you could dot it though your Macro at known points and set it to actually show Progress.

EXAMPLE Use Progress Bar as Warning not to Move Mouse.kmmacros (3.4 KB)
EXAMPLE Use Progress Bar as Warning not to Move Mouse

Here is how this simple Pulsing warning looks:

Screen Recording 2022-03-07 at 13.40.11-Animated GIFF 640 12fps

And here is one with the bar moving across to indicate progress (this is in an actual Macro I use for Backups). As the numbers and the title in the Progress Bar can be Variables it is open to all sorts of tweaks.

Screen Recording 2022-03-07 at 14.27.29-Animated GIFF 640 12fps

1 Like

Is the point of this request

(a) to stop the user from clicking, or
(b) to allow the user to click while not being able to move the mouse, or
(c) to stop both moving and clicking?

Even if it's not possible, you might be satisfied with a macro that, whenever the user moves the mouse, fills the screen with a big warning to not move the mouse, like this warning:

I haven't actually give up on the idea of stopping the mouse. I'm still researching that, but I suspect you might like a warning macro just as much. If you are happy with a warning, I can write that up for you. In fact, it looks so fun I'm going to write it up whether you want it or not, and I'll post it in the Macros forum on this website.

Maybe, or maybe not. If the mouse is Bluetooth mouse, then there's probably a way. That's because there are ways in macOS to reconfigure and relaunch the bluetooth daemon, something like this: (you may need to sudo to achieve this, and if you don't know how to sudo, you shouldn't be trying this until it's debugged. This code doesn't seem to work on Monterey. It may have worked on other versions of macOS.)

defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0
launchctl unload /System/Library/LaunchDaemons/com.apple.Bluetooth.plist
launchctl load /System/Library/LaunchDaemons/com.apple.Bluetooth.plist

There are also utilities that let you disable specific bluetooth devices, (you have to insert the bluetooth address of your mouse to make this work) like this:

$ brew install bluetoothconnector
$ BluetoothConnector --connect 00-11-22-33-44-55 --notify
$ BluetoothConnector --disconnect 00-11-22-33-44-55

A thorough discussion of either of the above options may require a new thread. However I'm working on a third and maybe a fourth option that is so huge in scope it definitely requires its own thread.