cliclick is a macOS CLI tool for emulating mouse and keyboard events

Overview

cliclick Overview

cliclick (short for “Command Line Interface Click”) is a tool for executing mouse- and keyboard-related actions from the shell/Terminal. It is written in Objective-C and runs on OS X 10.15 or later.

For more information or for downloading a compiled binary, please take a look at cliclick’s homepage

Author: Carsten Blüm, Website: www.bluem.net

Usage

To get a quick first impression, this is what you will get when you invoke cliclick -h:

USAGE
  cliclick [-r] [-m ] [-d ] [-e ] [-f ] [-w ] command1 [command2]

OPTIONS
  -r          Restore initial mouse location when finished
  -m    The mode can be either “verbose” (cliclick will print a
              description of each action to stdout just before it is
              performed) or “test” (cliclick will only print the
              description, but not perform the action)
  -d  Specify the target when using the “p” (“print”) command.
              Possible values are: stdout, stderr, clipboard or the path 
              to a file (which will be overwritten if it exists).
              By default (if option not given), stdout is used for printing
  -e  Set an easing factor for mouse movements. The higher this
              value is (default: 0), the more will mouse movements seem
              “natural” or “human-like”, which also implies: will be slower.
              If this option is used, the actual speed will also depend
              on the distance between the start and the end position, i.e.
              the time needed for moving will be higher if the distance
              is larger.
  -f    Instead of passing commands as arguments, you may instead
              specify a file from which cliclick will read the commands
              (or stdin, when - is given as filename).
              Each line in the file is expected to contain a command
              in the same format/syntax as commands given as arguments
              at the shell. Additionally, lines starting with the hash
              character # are regarded as comments, i.e.: ignored. Leading
              and trailing whitespace is ignored, too.
  -w     Wait the given number of milliseconds after each event.
              If you find that you use the “wait” command too often,
              using -w could make things easier. Please note that “wait”
              is not affected by -w. This means that invoking
              “cliclick -w 200 wait:500” will wait for 700 milliseconds.
              The default (and minimum) value for -w is 20.
  -V          Show cliclick version number and release date
  -o          Open version history in a browser
  -n          Send a donation

COMMANDS
To use cliclick, you pass an arbitrary number of commands as arguments. A command consists of a command identifier (a string that tells cliclick what kind of action to perform) and usually one or more arguments to the command, which are separated from the command identifier with a colon. Example: “c:123,456” is the command for clicking (the “c” is the command identifier for clicking) at the position with x coordinate 123 and y coordinate 456. See below for a list of all commands and the arguments they expect.
Whenever a command expects a pair of coordinates, you may provide relative values by prefixing the number with “+” or “-”. For example, “m:+50,+0” will move the mouse 50 pixels to the right. Of course, relative and absolute values can be mixed, and negative values are possible, so “c:100,-20” would be perfectly valid. (If you need to specify absolute negative values in case you have a setup with a second display arranged to the left of your main display, prefix the number with “=”, for instance “c:100,=-200”.)

LIST OF COMMANDS

  rc:x,y  Will RIGHT-CLICK at the point with the given coordinates.
          Example: “rc:12,34” will right-click at the point with x coordinate
          12 and y coordinate 34. Instead of x and y values, you may
          also use “.”, which means: the current position. Using “.” is
          equivalent to using relative zero values “c:+0,+0”.

  m:x,y   Will MOVE the mouse to the point with the given coordinates.
          Example: “m:12,34” will move the mouse to the point with
          x coordinate 12 and y coordinate 34.

  kd:keys Will trigger a KEY DOWN event for a comma-separated list of
          modifier keys. Possible keys are:
            - alt
            - cmd
            - ctrl
            - fn
            - shift
          Example: “kd:cmd,alt” will press the command key and the
          option key (and will keep them down until you release them
          with another command)

  kp:key  Will emulate PRESSING A KEY (key down + key up). Possible keys are:
            - arrow-down
            - arrow-left
            - arrow-right
            - arrow-up
            - brightness-down
            - brightness-up
            - delete
            - end
            - enter
            - esc
            - f1
            - f2
            - f3
            - f4
            - f5
            - f6
            - f7
            - f8
            - f9
            - f10
            - f11
            - f12
            - f13
            - f14
            - f15
            - f16
            - fwd-delete
            - home
            - keys-light-down
            - keys-light-toggle
            - keys-light-up
            - mute
            - num-0
            - num-1
            - num-2
            - num-3
            - num-4
            - num-5
            - num-6
            - num-7
            - num-8
            - num-9
            - num-clear
            - num-divide
            - num-enter
            - num-equals
            - num-minus
            - num-multiply
            - num-plus
            - page-down
            - page-up
            - play-next
            - play-pause
            - play-previous
            - return
            - space
            - tab
            - volume-down
            - volume-up
          Example: “kp:return” will hit the return key.

  tc:x,y  Will TRIPLE-CLICK at the point with the given coordinates.
          Example: “tc:12,34” will triple-click at the point with x
          coordinate 12 and y coordinate 34. Instead of x and y values,
          you may also use “.”, which means: the current position.
          Note: If you find that this does not work in a target application,
          please try if double-clicking plus single-clicking does.

  ku:keys Will trigger a KEY UP event for a comma-separated list of
          modifier keys. Possible keys are:
            - alt
            - cmd
            - ctrl
            - fn
            - shift
          Example: “ku:cmd,ctrl” will release the command key and the
          control key (which will only have an effect if you performed
          a “key down” before)

  dm:x,y  Will continue the DRAG event to the given coordinates.
          Example: “dm:112,134” will drag and continue to the point with x
          coordinate 112 and y coordinate 134.

  c:x,y   Will CLICK at the point with the given coordinates.
          Example: “c:12,34” will click at the point with x coordinate
          12 and y coordinate 34. Instead of x and y values, you may
          also use “.”, which means: the current position. Using “.” is
          equivalent to using relative zero values “c:+0,+0”.

  dd:x,y  Will press down to START A DRAG at the given coordinates.
          Example: “dd:12,34” will press down at the point with x
          coordinate 12 and y coordinate 34. Instead of x and y values,
          you may also use “.”, which means: the current position.

  w:ms    Will WAIT/PAUSE for the given number of milliseconds.
          Example: “w:500” will pause command execution for half a second

  p[:str] Will PRINT the given string. If the string is “.”, the current
          MOUSE POSITION is printed. As a convenience, you can skip the
          string completely and just write “p” to get the current position.
          Example: “p:.” or “p” will print the current mouse position
          Example: “p:'Hello world'” will print “Hello world”

  du:x,y  Will release to END A DRAG at the given coordinates.
          Example: “du:112,134” will release at the point with x
          coordinate 112 and y coordinate 134.

  cp:str  Will PRINT THE COLOR value at the given screen location.
          The color value is printed as three decimal 8-bit values,
          representing, in order, red, green, and blue.
          Example: “cp:123,456” might print “127 63 0”

  dc:x,y  Will DOUBLE-CLICK at the point with the given coordinates.
          Example: “dc:12,34” will double-click at the point with x
          coordinate 12 and y coordinate 34. Instead of x and y values,
          you may also use “.”, which means: the current position.

  t:text  Will TYPE the given TEXT into the frontmost application.
          If the text includes space(s), it must be enclosed in quotes.
          Example: “type:Test” will type “Test” 
          Example: “type:'Viele Grüße'” will type “Viele Grüße”

Limitations

It is not possible to use cliclick before a user logs in, i.e.: to control the login window.

Building cliclick

Either build in Xcode, as usual, or build from the shell by cding into the project directory and then invoking either xcodebuild or make (whatever you prefer). In either case, cliclick will not be installed, but you will simply get an executable called “cliclick” in the project directory which you can then move wherever you want to have it. (You can put it anywhere you like.) To install it to /usr/local/bin, you can also simply invoke sudo make install, which will do this for you.

Please note that while the code will run on OS X 10.9 and later, Base SDK and architectures selected in the Xcode project are set to the current SDK. Therefore, if you want to build for an older system, be sure to change these settings accordingly. If you have problems when building and get a message complaining about undefined symbols, chances are that this can be fixed by disabling “Implicitly link Objective-C Runtime Support” in the build settings.

Contributing

If you would like to contribute a new feature, a bugfix or other improvement, please do so using a pull request. However, please take care that:

  • There is one pull request per topic. I.e.: if you would like to contribute a new feature and two bugfixes, open three pull requests.
  • All commit messages are in English.
  • Ideally, all non-obvious features or changes should be shortly explained. This might not only include what you committed, but also why you did it (motivation, usage scenario, …).
Issues
  • Command

    Command "t" returns segmentation fault

    OS: 10.11 2015-10-05 04 36 48

    bug 
    opened by xream 17
  • Mojave 10.14 support

    Mojave 10.14 support

    It totally doesn't work on Mojave 10.14. I tried to build it (sudo make install), build process was successful, but the result was the same as when I just install cliclick using homebrew or downloading from the site.

    When I try some command I see typical message (verbose mode), but nothing happens.

    opened by apximax 10
  • Implement scrolling

    Implement scrolling

    opened by wfaulk 8
  • More “human-like” mouse movements (easing)

    More “human-like” mouse movements (easing)

    For purposes such as scripting screencasts, where things like the movement of the mouse pointer should be perceivable (instead of the mouse jumping around the screen, which is what happens when using cliclick now), it would be nice to have mouse movement easing – probably cubic in/out easing.

    This means that a whole series of mouse move events would have to be fired to emulate this.

    Reminder: for calculating the easing, this would be sufficient:

    // Modeled after the piecewise cubic
    // y = (1/2)((2x)^3)       ; [0, 0.5)
    // y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
    //
    // Source: AHEasing, License: WTFPL
    //
    // Expects the [whatever action] to be split up into small steps represented
    // by a float from 0 (start) to 1 (end). Method is to be called with the float
    // and returns an "eased float" for it.
    -(float)cubicEaseInOut:(float)p {
        if (p < 0.5) {
            return 4 * p * p * p;
        } else {
            float f = ((2 * p) - 2);
            return 0.5 * f * f * f + 1;
        }
    }
    
    enhancement 
    opened by BlueM 7
  • How can I change the default delay to 20ns instead of 20ms?

    How can I change the default delay to 20ns instead of 20ms?

    I tried changing waitingTime.nsec to 0 everywhere but it didn't seem to have an effect. How can I set the delay to 20 nanoseconds instead of milliseconds.

    question 
    opened by whimsica 7
  • In OS X 10.11 (El Capitan), the click command does not work sometimes

    In OS X 10.11 (El Capitan), the click command does not work sometimes

    I'm using c:x,y to click on an application control, but it does not click on the location sometimes. It seems like the click is initiated but not released. I have used cliclick with OS X 10.9 and 10.10 as well but there was never such an issue. Can you help m fix this?

    opened by sakshigoyal369 6
  • Key press does not work on russian keyboard on OS X 10.12.6

    Key press does not work on russian keyboard on OS X 10.12.6

    I'm using cliclick to test hotkeys in my app. For example it presses control+shift+v. And the test runs on english and russian keyboards. But now then i run it on mac with 10.12.6 on board I get only control+shift when i switch to russian. Button "V" is ignored. It worked in earlier versions of OS X.

    opened by undsett 6
  • How to do cmd-C, cmd-V, cmd-X ...

    How to do cmd-C, cmd-V, cmd-X ...

    How can you generate keyboard sequences like Copy, Paste etc. ? I tried 'cliclick kd:cmd t:v ku:cmd' but that just prints out v instead of triggering a copying event. If this isn't possible yet, I am happy to add something along the line of:

    • ad:, trigger key down event for key
    • au:, trigger key up event for key

    or extend kd, ku to take a key code in addition to the current special keys

    Any feedback would be helpful

    bug 
    opened by ccc-tomr 6
  • FeatureRequest: Support Mouse Down, Mouse Up - Not

    FeatureRequest: Support Mouse Down, Mouse Up - Not "just" Mouse Click

    Hi Carsten,

    After an upgrade to Sierra I had to realize that Karabiner/Seil are not working anymore, for the following use case: I could, before the update, bind a key to the left mouse button, e.g. in their config format:

      KeyCode::D, ModifierFlag::OPTION_R | ModifierFlag::NONE,
      PointingButton::LEFT
    

    (and option-r was remapped to caps-lock via seil)

    That enabled me to do this:

    1. caps-lock + d -> mouse down (e.g. on start of text to select, e.g. on window border, with left hand)
    2. trackpad move pointer to destination (with right hand)
    3. release d and caps lock

    This was amazingly effective, far more precise then clicking on the trackpad and less strain, basically just like tapping - but without having to move the hand away from the default typing position....

    With cliclick I can't get it, since you 'just' support a full click but not a seperate mouse down / mouse up and drag did also not really work, e.g.:

    #!/usr/bin/env bash
    while true; do
        sleep 1
        echo down
        ./cliclick dd:.
        sleep 1
        echo up
        ./cliclick du:.
    done
    

    and then moving the pointer over text did not select in the browser and also not move any window when I move over its border while the the script is running.


    Note: Tried to mess around a few hours with swift and obj.c - but to no success, could not really emulate a left mouse button down / up only, at the current track pad position. Only managed to get same behaviour like pressing the '5' key on the numeric keyboard when the MouseEvents feature is on - but that allows not to drag, after 5 is down, dragging works then only with the other numeric keys. Crazy...

    Maybe you find it trivial, sort of my last hope,

    Cheers from Nr. 400 ;-)

    opened by AXGKl 6
  • What is *** setObjectForKey: key cannot be nil

    What is *** setObjectForKey: key cannot be nil

    I cannot execute any command.

    opened by CristianCardosoA 6
  • Is there a parameter to control the speed of keyboard input?

    Is there a parameter to control the speed of keyboard input?

    i want control the speed of t:text ,i see

    -e <easing> Set an easing factor for mouse movements.
    

    but not find the type text speed parameter

    question 
    opened by zphj1987 1
  • zsh: killed     /usr/local/bin/cliclick

    zsh: killed /usr/local/bin/cliclick

    When I try to run cliclick on my M1 Mac running macOS 11.4 Big Sur I get an error in standard output that it was killed:

    zsh: killed /usr/local/bin/cliclick

    macOS logs state "ASP: Security policy would not allow process: 1715, /usr/local/bin/cliclick"

    question 
    opened by dstranathan 3
  • Add right mouse drag command

    Add right mouse drag command

    Commands:

    • ddr
    • dmr
    • dur
    opened by sdgandhi 0
  • Restore (-r) does not work with `cliclick -r m:100,100`

    Restore (-r) does not work with `cliclick -r m:100,100`

    I tried to move the mouse to the place 100,100 and then restore the previous position (-r), but the mouse stays at 100,100 and is not restored.

    watch -n 5 cliclick -r m:100,100
    
    or 
    
    cliclick -r m:100,100
    

    I try to prevent enabling the screensaver - which is at the moment managed by my company and is activated each 5 minutes when there was no activity. But this usage doesn't matter - I think we just have a bug in cliclick ;)

    $ sw_vers
    ProductName:	macOS
    ProductVersion:	11.0.1
    BuildVersion:	        20B50
    
    1 [email protected]:~
    $ cliclick -h
    
    cliclick (short for “Command Line Interface Click”) is a tool for executing mouse- and keyboard-related actions from the shell/Terminal
    
    USAGE
      cliclick [-r] [-m <mode>] [-d <target>] [-e <num>] [-f <file>] [-w <num>] command1 [command2]
    
    OPTIONS
      -r          Restore initial mouse location when finished
    
    ....
    
    Version 4.0.1, released 2018-04-10
    Author: Carsten Blüm, <[email protected]>
    List of contributors: https://github.com/BlueM/cliclick/graphs/contributors
    Website: https://www.bluem.net/jump/cliclick/
    
    possibly bug 
    opened by tobiashochguertel 2
  • Add function prototypes to interface

    Add function prototypes to interface

    At the point where distanceBetweenPoint or cubicEaseInOut are invoked, old compilers complain:

    error: incompatible types in initialization
    

    This is solved by declaring the function prototypes in the interface.

    opened by ryandesign 1
  • Simultaneous keystrokes (with non-modifier keys)

    Simultaneous keystrokes (with non-modifier keys)

    Hello, is it possible to send two (or more) simultaneous keystrokes of just any individual keys?

    For example, something liket:eu but instead of 'typing' the two letters one after the other to actually press the keys simultaneously?

    Thanks!

    p.s. I'm using clickclick with ShockEmu to emulate sending commands to my (virtual) PS4 controller, where I need to activate a combo-command requiring to press two keys of the virtual gamepad simultaneously.

    question 
    opened by NMichas 1
  • unable to activate iTerm2 tab with clicklick

    unable to activate iTerm2 tab with clicklick

    When trying to activate iTerm2 tab (with mouse over tabbar) with clicklick c:. it doesn't work. Curiously clicklick dc:. (double click) - works

    opened by yatsek 1
  • dd and du do not seem to click-and-hold on 10.14.6 Mojave...

    dd and du do not seem to click-and-hold on 10.14.6 Mojave...

    I've tested with a few other similar tools (not as elegant as yours) that do work. So Apple hasn't disabled some feature.

    I've installed from homebrew, and it gives me this version:

    cliclick 4.0.1, 2018-04-10
    

    The cursor visibly moves with all my commands. But clicks do not happen. I've tried inserting high wait times between dd and du, I've tried using the -e switch all the way up to 9. I've confirmed manually that there is text to select/highlight (eyeballing it, but I'm not off more than 50 pixels plus-minus on either coordinate). I've tried a m/move command in between rather than a du, and then I do a du:.

    I thought at first this might be the app I was using it on (not Applescriptable), but even in Firefox I get the same results. I'm likely doing something dumb, but I can't figure out what that might be.

    question 
    opened by NoMoreNicksLeft 1
  • QUESTION It has a delay to execution

    QUESTION It has a delay to execution

    Using Catalina 10.15.4 using the Version 4.0.1, released 2018-04-10

    I`ve noticed a delay between the execution, sometimes 500ms,1s

    Is this caused by the app or by the time it opens the script in memory and there is nothing that can be tweked?

    question 
    opened by cotfas 1
  • Percentage positioning feature suggestion

    Percentage positioning feature suggestion

    Feature suggestion: I appreciate the value of pixel-perfect mouse positioning, but I occasionally have "looser" requirements for mouse movements, and would love to be able to move the mouse to, say, 25% of the way across and 40% of the way down the screen, without concern for the resolution of the current display.

    Of course, this is a lovely way to get to the center of the screen, too, without wrapping the call in external math.

    If get some free time sometime soon, I'll take a shot at it myself and send a pull request if it proves to be slick.

    enhancement 
    opened by bland328 2
 OS X command line tools for developers – The ultimate tool to manage your Mac. It provides a huge set of command line commands that automatize the usage of your OS X system.

Mac CLI  macOS command line tools for developers ⭐ Now with modularity and plugins! You can check the plugins folder: /mac-cli/plugins Contributions

Gabriel Guarino 8.1k Sep 21, 2021
Mac App Store command line interface

mas-cli A simple command line interface for the Mac App Store. Designed for scripting and automation. ?? Install ?? Homebrew Homebrew is the preferred

mas-cli 8.4k Sep 20, 2021
 Swiss Army Knife for macOS

 m-cli ?? Swiss Army Knife for macOS ! Overview Install Uninstall How To Use All Commands Contributing Overview m-cli is a macOS command line tool th

Roger 8.5k Sep 21, 2021
Move files and directories to the trash

Move files and folders to the trash Works on macOS (10.12+), Linux, and Windows (8+). Note: The Linux implementation is not very good and not maintain

Sindre Sorhus 2.2k Sep 15, 2021
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

null 52k Sep 15, 2021
Command-line tool that instantly fetches Stack Overflow results when an exception is thrown

rebound Rebound is a command-line tool that instantly fetches Stack Overflow results when an exception is thrown. Just use the rebound command to exec

Jonathan Shobrook 3.7k Sep 19, 2021
A cat(1) clone with wings.

A cat(1) clone with syntax highlighting and Git integration. Key Features • How To Use • Installation • Customization • Project goals, alternatives [中

David Peter 29.5k Sep 24, 2021
:rocket::star: A Zsh prompt for Astronauts

?? ⭐ Spaceship ZSH Zsh prompt for Astronauts. Website | Install | Features | Options | API Built with ❤︎ by Denys Dovhan and contributors Spaceship is

Denys Dovhan 15.2k Sep 16, 2021
Control the macOS dark mode from the command-line

dark-mode Control the macOS dark mode from the command-line Requires macOS 10.10 or later. macOS 10.13 or earlier needs to download the Swift runtime

Sindre Sorhus 587 Sep 6, 2021
💡 CLI tool to input and store your ideas without leaving the terminal

eureka eureka is a CLI tool that allows you to quickly write down an idea using your preferred editor, and then have the idea committed and pushed to

Simon Egersand 391 Sep 19, 2021
Git-integrated backup tool for macOS and Linux devs.

shallow-backup shallow-backup lets you easily create lightweight backups of installed packages, applications, fonts and dotfiles, and automatically pu

Aaron Lichtman 786 Sep 17, 2021
A code-searching tool similar to ack, but faster.

The Silver Searcher A code searching tool similar to ack, with a focus on speed. Do you know C? Want to improve ag? I invite you to pair with me. What

Geoff Greer 22.6k Sep 23, 2021
Terminal session recorder 📹

Note: This is README for development branch. See the version for latest stable release. asciinema Terminal session recorder and the best companion of

asciinema 9.6k Sep 22, 2021
The best command-line tool to install and switch between multiple versions of Xcode.

xcodes The best command-line tool to install and switch between multiple versions of Xcode. If you're looking for an app version of xcodes, try Xcodes

Robots and Pencils 917 Sep 19, 2021
Find files with SQL-like queries

fselect Find files with SQL-like queries Why use fselect? While it doesn't tend to fully replace traditional find and ls, fselect has these nice featu

null 3k Sep 15, 2021
A terminal spreadsheet multitool for discovering and arranging data

VisiData v2.4 A terminal interface for exploring and arranging tabular data. VisiData supports tsv, csv, sqlite, json, xlsx (Excel), hdf5, and many ot

Saul Pwanson 4.2k Sep 23, 2021
A new type of shell

README Nushell A new type of shell. Status This project has reached a minimum-viable product level of quality. While contributors dogfood it as their

Nushell Project 15.9k Sep 24, 2021
Postgres CLI with autocompletion and syntax highlighting

A REPL for Postgres This is a postgres client that does auto-completion and syntax highlighting. Home Page: http://pgcli.com MySQL Equivalent: http://

dbcli 9.8k Sep 23, 2021
Tasks, boards notes for the command-line habitat

Taskbook Tasks, boards & notes for the command-line habitat Description By utilizing a simple and minimal usage syntax, that requires a flat learning

Klaus Sinani 8.2k Sep 18, 2021