Moving the Mouse like a Human would

Here's a set of macros that lets you record and play back human mouse movements for automating very smooth/human-like mouse movements in Keyboard Maestro. I just wrote it today, but even though it's a new rewrite of old code, I think it's bug free. But let me know if you find any problems.

The KM action "Move Mouse" is good for basic/autonomous mouse movement, but it doesn't do the job in an aesthetic or human-like way. These macros will let you record and play back human motion, which can be used for purely aesthetic reasons or perhaps for passing server/captcha "human tests."

Mouse, Human Motion Macros.kmmacros (45.4 KB)

As documented in the macro, you will need to set up at least one mouse path using the Mouse Recorder macro. It's better to set up two or three paths first, then run the Mouse Test macro to see the mouse moved randomly using your recorded paths.

4 Likes

Could you explain how to record the mouse movement and how to choose a path?
Can't seem to figure it out

Thanks in advance

If you run the macro Mouse Recorder you will get this dialog box:

As the dialog box says, click on OK then move the mouse from the upper left corner of the screen to the lower right.

Once you do that you will get this:

If you press CONTINUE, the mouse movement that you created from the upper left to lower right of the screen will be "recorded."

In order to run any macro, like the Mouse Recorder macro, you can either assign a hotkey to it and press the hotkey, or use the KM Editor to activate it, typically by selecting the macro and pressing the Run button.

Thanks, but when I run the recoreder I get the first message, when i click ok and moce the mouse to upper left en lower right, nothing happens and no messages appear...

Does your Mac have multiple monitors? I'm trying to figure out what could be causing your issue. My macro was not tested on a Mac with multiple monitors.

P.S. If you didn't get the second dialog box, then my macro may still be running and you will need to cancel all running macros, or use the debugger to stop my macro, or restart the engine.

Yes, I have multiple monitors, using mac studo m2 max 64GB

Aha! Either I have to add code to support multiple monitors, or I have to add code to tell the user that this macro won't work with multiple monitors.

I'll probably add code to support multiple monitors. That may take a little time to figure out. It never occurred to me to test my code for a multi-monitor user.

As a temporary fix, if you just temporarily disable your secondary monitor(s), the macro should record correctly, then you can re-attach your displays, and it should work fine.

Got it, so no lick for me on this one :slight_smile:
Hope you find a solution soon!

I will try to accommodate you, but you can use my temporary solution described in the last post.

Ok, you adjusted the post or you made e new one?

I added the following words to my post above:

Here's v1.1, which I think should support multi-monitors. But there are 100 different ways to configure and arrange multi-monitors, and I didn't test all of those arrangements! (I tested only my own temporary two-display arrangement, and it works for me.)

Mouse, Human Motion Macros v1.1.kmmacros (45.9 KB)

Hi! I just found your macro a year since this post and I am not able to run the TEST after recording several of the Mouse Recorders. It always shows the error that I have to have alteast one path loaded first but I have made 4 recordings that are being stored.

I am on my M1 mac with 15.6.1 with KM V.10.2 running. I Wasn’t sure if I missed a step in the directions or if it was a new macOS issue and or I need to upgrade to KM11?

Thanks!

I just re-downloaded my macro from my original post and ran it. It worked perfectly for me. So maybe you didn’t do the same thing as me. Or maybe there’s something unexpected about your hardware. For example, how many displays does your Mac have? And how do you know you have 4 recordings stored? Can you show any screenshot to confirm your claim about having four recordings stored?

I am not using any external displays and I have attached a screenshot from just now when I started the macro. I believe I followed the steps correctly to run the test but actually I am not certain how to record the mouse movements I actually want to run.

When I click mouse move action I also get this error, but that appears as soon as I click it.

Can you tell me if you are using the same macOS and what version of KM you are using?

Thanks!

I don’t use the same version of macOS or KM as you. I’m using up-to-date versions. Thanks for telling me, but so far I don’t think that’s the problem.

I don’t know what that means. In any case, that’s not how you test my macro. You don’t “click on an action” to test my macro. What you do is “run” the “Mouse Test” macro. There are many ways to run a macro, but in your case I recommend that you click on the macro name “Mouse Test” then click on the “Run” button on the very top of the KM Editor window. This could be your problem. Try this, then tell me if it worked.

Based on what you told me above, I’m not sure if you followed the steps correctly to run the test. Try my instructions in the previous paragraph and let me know what happened.

It may also be helpful to run the macro called “Mouse Recordings Erase” and then start over by recording some new mouse recordings using the “Mouse Recorder” macro.

Thanks again for the help,

Sorry about the lack of detail, I have read over the directions and followed them in order and have ran your erase command several times to start over the several times I have tried to use this and issue persists. I am also making sure to use the KM editor window and using the run button at the top of the window for each of those macros.

When I start with mouse recorder, I see the prompt screen to move the mouse from the UL to LR corners, I do this, I click ok, then I click continue and follow the suggestions to do this several more times. Then I run Mouse test to see if it worked and this window appears the progress bar moves back and forth and never runs anything. For testing purpose I decided to try mouse Move and thats when that other error appears, “Macro Cancelled”

I might be reading it wrong, but the mouse recorder macro always has us go from UL to LR corners of the display, is this a one time thing to test and then you are to ignore it and do your normal mouse movements you want to run? The directions are not clear here.

Thanks!

No, this is not a “one time thing to test,” this is how your mouse movements are collected. You must have done this correctly at least 6 times because one of your screenshots says that you have 6 mouse movements stored.

One thing that you probably should do is re-read the my posts above and replace your version with the v1.1 version that was posted further down the thread. I can’t remember what changes I made between 1.0 and 1.1. Based on your screen shot you are using the older version.

Perhaps I should make a video of the macro working and post that video on this site so that people can see how the macro should be run. As you said, my directions are not clear, and I accept that statement. So maybe I need a video. I’ll look into it.

BREAKING NEWS: This time I was able to replicate your problem! That’s good news, because it means I can debug the issue. For the last hour I didn’t have your problem, so there was not much I could do.

EDIT: Okay, I think I figured it out. But I’m not sure if you are running v1.0 or v1.1, both of which are posted in the thread above. In v1.1, the final two actions in the “Move Mouse” macro need to be disabled. I don’t understand why I left them in there. Here is an image of the two actions that need to be disabled. Of course, I will upload a corrected version, but it would be helpful if you confirm that this fixes the problem.

Hello again!

Thanks so much for looking into this. I am running 1.1, sorry I should have stated that sooner as well. So based on your screenshot I am not seeing those two actions in the Move Mouse Macro.

This is what I see when I go into that macro:

When I expand the “If all conditions met execute Actions” inside of Mouse Move drop down I see this:

What I find interesting is that when I went into the Mouse Test macro to have a look at it I saw the mouse move macro, when I disabled it I see dots on my screen as before I was only getting a loading bar saying looking for path. However it does not stop for me when I move the mouse like it says:

Well, I think it’s working and you don’t realize it. You see those blue circles? Those represent the path that the mouse is randomly taking using the recorded path(s) that you installed into the macro. Every single pixel that the mouse moves between those blue circles is being calculated from one of the paths that you previously recorded. There’s a lot of calculations going on while that Test Macro is running. If you look closely, you will notice that the path the mouse takes between each circle is a scaled replica of one of the path(s) that you recorded.

In order to stop the test macro from running, one method is to move the mouse to the top pixel of the screen. You may have to “fight” the macro a little bit as it is moving the mouse pointer itself.

I can’t explain what your problem was right now, and I’m sorry for asking you to disable two actions that don’t exist (I probably added them after uploading the macro) but please consider my words above and look closely, you may discover that it’s working as intended. At least that’s what your latest screen shot suggests to me.

You could also try creating your own test macro that moves the mouse from place to place. The whole purpose of my utility is to let you move the mouse, so you should try it yourself, rather than just run my test macro.