Repeat the Next Mouse Click 'x' times

Is anyone willing to give an opinion on this macro?

It is working, but I wonder if the script can be more elegant.

It will repeat the NEXT mouse click a specified number of times.

It is designed for on screen buttons or arrows with no keystroke option, that sometimes need to be clicked many times to get a desired result.

It comes with some risk, if you click the wrong thing 100 times, it could get you in some trouble.

For now, it has a 25 click limit, just to be safe

Clickanator.kmmacros (10 KB)

1 Like

Well that's dicey.. you're right to approach with caution.

Are the clicks in a webpage? If so, the javascript to send a click to any screen element is fairly simple, and will be more reliable. I recently posted a macro that clicks the "Next" control on the youtube video player, if you need a sample.

Perhaps for over the 25 click limit you could pause with a dialog, asking the user if they wish to continue?

(and don't spend all that ad-click revenue in one place haha :grin:)

Ha! I wasn’t thinking of web browsers, but some of the deeper dialogs inside Finale.
There are arrow buttons for some functions that do not have keyboard or menu equivalents.

Hey Mike,

Any special reason you used an AppleScript dialog instead of a Prompt for User Input action?

You don't need the pause-until for prompt. Keyboard Maestro will wait until that action finishes before advancing – unless you turn on asynchronous in the Execute an AppleScript action.

I'd put in a IF-THEN with a Key-Condition, such that if the spacebar (or whatever) was down the macro would abort. It's a good idea to put a kill switch in any macro that "goes crazy" like this one.

It's a good idea to have a global cancel-all-macros macro as well.


The 1st pause waits for the dialog to close. Without the pause, if the user clicked the OK button (rather than pressing return) it repeated the OK button click.

And yes I have a Cancel All macro!

The 2nd pause is essentially a trigger to get the mouse location.

I’m using AppleScript simply because I’m trying to learn it!

The kill switch idea is a good one.
I might try the reverse to - it only works WHILE holding a certain key down.
Something akin to the safety trigger on a power tool

1 Like

Here's an update:

I've added some more few safety features.

The User must hold control-option-shift through the entire process, or the macro aborts.
I like this option as it keeps the user active in the process.

Also for safety, I've also slowed the automation down to a less frantic pace.

Clickanator v1.1.kmmacros (12.0 KB)