MacOS – How to automate repeat mouse clicks, with delay, from fixed coordinates within a browser window

applescriptautomatorclickgoogle-chromemacos

Looking for a quick and dirty way to automate this mundane activity. I presume this could be done with an automation to press the mouse button from two separate pixel coordinates, with delay, so long as the browser window doesn't move — unless there's a better way.

I tried building a Watch Me Do workflow, in Automator, but can't seem to get it to work. I get the error "application Chrome is not running when it is expected to." It also never lists mouse clicks for some reason.

I do have accessibility set up, in system preferences > security & privacy > privacy > accessibility. Automator, Chrome and System Events are all checked within there (among other stuff of course).

I tried the markashworth workaround as detailed here — which also doesn't seem to work. Using his method, I get this error:

enter image description here

UPDATE: I just downloaded "cliclick" and figured out how do both clicks as a terminal command, with the proper delays. BUT — I don't know code and need a way for this terminal command to repeat "x" amount of times. Anyone know how I could do that in Script Editor? The command line is:

cliclick c:132,286 w:100 c:132,286 w:5000 c:1100,238

I would need a few seconds of delay before the loop repeats, which I presume I could do with a final "w:" in that line. Thanks for the help!!

Best Answer

There is a much easier way to do this on the Mac: Keyboard Maestro.

Despite the name, it automates the mouse as well as the keyboard.

It let you use GUI tools to setup the clicks (all you have to go is tell it to watch where you click, then click, and it will do the calculation for you).

It will let you set a specific delay between the clicks.

It also has built-in tools for clicking links in Safari and Chrome, which may also help.

It will also let you use AppleScript or JavaScript (or anything else) as part of the macro.

All of the actions are drag-and-drop.

There is a very active forum where lots of helpful users hang out (and also the developer of the program).

There are about 1,000 other things you can do with Keyboard Maestro too. Once you start using it, you'll realize all the ways it can help.

(To be clear, I have absolutely no connection to the app except being an extremely grateful user for a number of years. I pay for my own upgrades as soon as a new version comes out because it's the most useful utility on the Mac.)