How to automate mouse click on Mac


To automate the mouse click action on macOS, use Cliclick, a CLI for emulating mouse events, and AppleScript.

Cliclick

Install cliclick with Homebrew:

brew install cliclick

To click at the current mouse location:

cliclick c:.

This is the same as running with the full binary path:

/usr/local/bin/cliclick c:.

AppleScript

Open Script Editor with Spotlight and paste the AppleScript code:

delay 15

repeat 10 times
    do shell script "/usr/local/bin/cliclick c:."
    delay 1
end repeat

AppleScript requires the full binary path to run cliclick.

The script does the following:

  1. Wait 15 seconds (line 1).
  2. Click at the current mouse location (line 4).
  3. Wait 1 second (line 5).
  4. Repeat steps 2 to 3 nine more times (lines 3-6).

To run the script, press the play button or ⌘+R (Command-R). To stop the script, press the stop button or ⌘+. (Command-Period). See keyboard shortcuts in Script Editor on Mac.



Please support this site and join our Discord!