If I position my mouse cursor at a certain point on the screen, is it possible to use the Automator or AppleScript to "click" the mouse, enter a keyboard shortcut (say, command-5), press the return key, and then repeat those three things n times?
How to automate mouse clicks and keyboard input with Automator in Mac Mojave
applescriptautomator
Related Question
- Change keyboard whenever iTerm is selected
- Automator Service that works with and without selection
- MacOS – How to make a colour clicker using AppleScript
- Script/Workflow: Select item, print, save as PDF, name sequentially, down arrow to next item
- MacOS – How to restart a currently-running application with AppleScript
- Is it possible to change the “Ignore built-in trackpad when mouse is present” setting with a keyboard shortcut
- MacOS – How to automate repeat mouse clicks, with delay, from fixed coordinates within a browser window
Best Answer
This code requires the third-party utility, Cliclick.
It's free to download but it's donationware, and is easy to install.
On my system I have.
cliclick
in the following directory:/usr/local/bin/
. Because of this location, in my AppleScript code and in Terminal app, I need to use the full path tocliclick
to call the command. For example:do shell script "/usr/local/bin/cliclick c:."
In AppleScript it's tellingcliclick
to click at current mouse location.This AppleScript code works for me using the latest version of macOS Mojave.