How to automate mouse click on Mac
1 min readDec 17, 2020
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:
AppleScript requires the full binary path to run
cliclick
.
The script does the following:
- Wait 15 seconds (line 1).
- Click at the current mouse location (line 4).
- Wait 1 second (line 5).
- 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.