cliclick

repository·master·Indexed 24 days ago

https://github.com/bluem/cliclick

A command-line tool for emulating mouse clicks and keyboard typing on macOS. It supports absolute and relative coordinate movements, various click types (single, double, triple, right-click), dragging, and keyboard character emulation across multiple layouts. The tool can be installed via Homebrew or MacPorts and requires Accessibility permissions to control the computer.

Tokens
1.4K
Snippets
0
Records
7
Agent score
34%

What's inside cliclick

  1. How cliclick commands are structured

    master

    cliclick executes actions via a series of commands passed as arguments. Each command follows a specific syntax:

    [command_identifier]:[arguments]

    • Command Identifier: A string representing the action (e.g., c for click, m for move).
    • Arguments: Usually coordinates (x,y) or keys, separated from the identifier by a colon.

    Coordinate Syntax

    When a command requires coordinates, you can use:

    • Absolute values: x,y (e.g., c:123,456)
    • Relative values: Prefix with + or - (e.g., m:+50,-10 moves the mouse 50px right and 10px up).
    • Current position: Use . as a shorthand for the current mouse position (e.g., c:. is equivalent to c:+0,+0).
    • Absolute negative values: For displays arranged to the left of the main display, prefix the number with = (e.g., c:100,=-200).
  2. How cliclick handles character emulation and keyboard layouts

    master

    cliclick emulates typing by simulating physical key presses (regular keys, or combinations with Shift and/or Alt), making it independent of the current keyboard layout.

    For characters that require multiple keystrokes (like "dead" keys or combining characters), cliclick uses specific sequences. For example, on a German keyboard, to type é, it can simulate a combining acute accent (Unicode U+0301) followed by e.

    If a character is not working, it is likely because the specific keyboard layout's mapping is incomplete in the source code.

  3. How to add support for new characters or keyboard layouts

    master

    If cliclick cannot type a character you need, you can extend its support by modifying the source code.

    Note: Do not edit README-Characters.md manually, as it is auto-generated from the source code.

    To add support:

    1. Locate the method getReplacementMapForKeyboardLayoutNamed: in KeycodeInformer.m.
    2. Add the necessary logic to map the desired characters to their respective key sequences for the target layout.
    3. Rebuild the project to update the character maps.
  4. Install cliclick via Homebrew or MacPorts

    master

    To install cliclick without building from source, it is strongly recommended to use Homebrew. cliclick is also available on MacPorts, though MacPorts may not always provide the most recent version.

    Important: Accessibility Permissions After installation, you must grant your terminal emulator (e.g., Terminal, iTerm) permission to control the computer.

    Navigate to: System PreferencesSecurityAccessibility and ensure your terminal application is enabled. If permissions are missing, cliclick will execute but no actions will occur (a warning will be written to stderr in version 5.1+).

  5. cliclick mouse commands

    master

    Use these commands to control the mouse cursor:

    CommandSyntaxDescription
    cc:x,yClick at coordinates. Use . for current position.
    dcdc:x,yDouble-click at coordinates.
    tctc:x,yTriple-click at coordinates.
    rcrc:x,yRight-click at coordinates.
    mm:x,yMove mouse to coordinates.
    dddd:x,yPress down to start a drag at coordinates.
    dmdm:x,yDrag and continue to coordinates.
    dudu:x,yRelease to end a drag at coordinates.
    cpcp:x,yPrint color (RGB) at coordinates.
    pp[:str]Print a string or the current mouse position (p:.).

    Example: Dragging the mouse

    cliclick dd:100,100 dm:200,200 du:200,200
  6. cliclick CLI options reference

    master

    Use the following flags to modify the behavior of cliclick execution:

    FlagDescription
    -rRestore initial mouse location when finished.
    -m <mode>Set mode to verbose (print description to stdout before action) or test (print description but do not perform action).
    -d <target>Specify where the p (print) command outputs. Values: stdout (default), stderr, clipboard, or a file path.
    -e <easing>Set an easing factor for mouse movements. Higher values make movements more "human-like" and slower.
    -f <file>Read commands from a file or stdin (if - is used). Lines starting with # are ignored.
    -w <num>Wait <num> milliseconds after every event. This is additive with the w command (e.g., -w 200 w:500 results in a 700ms wait).
    -VShow version number and release date.
    -oOpen version history in a browser.
    -nSend a donation.
  7. Supported and unsupported characters by keyboard layout

    master

    The following list details which characters are supported or unsupported across various keyboard layouts. Note that unsupported lists are often incomplete.

    Canadian French - CSA

    • Supported: ÄËÏÖÜŸäëïöüÿÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÂÊÎÔÛâêîôûÃÑÕãñõ
    • Unsupported: ŇŘŠňřšǸǹŃńÅåŮů

    French

    • Supported: ÄËÏÖÜŸäëïöüÿÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÂÊÎÔÛâêîôû
    • Unsupported: ÃÑÕãñõŃńǸǹŇňŘřŠšŮů

    German

    • Supported: ÄËÏÖÜŸäëïöüÿÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÂÊÎÔÛâêîôûÃÕÑãõñ
    • Unsupported: ŃńǸǹŇňŘřŠšŮů

    Italian

    • Supported: ÄËÏÖÜŸäëïöüÿÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÂÊÎÔÛâêîôûÑñÃÕãõ
    • Unsupported: ŸŇŘŠňřšǸǹŃńŮů

    Polish

    • Supported: ÄÖÜäöüÁÉÍÓÚáéíóúŃńŇňŘřŠš
    • Unsupported: ËÏŸëïÿÀÈÌÒÙàèìòùǸǹÂÊÎÔÛâêîôûÃÕÑãõñŒœÅåØøÆæ

    Portuguese

    • Supported: ÄËÏÖÜäëïöüÿÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÂÊÎÔÛâêîôûÑñÃÕãõ
    • Unsupported: ŸŇŘŠňřšǸǹŃńŮů

    Spanish

    • Supported: ÄËÏÖÜŸäëïöüÿÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÂÊÎÔÛâêîôûÑñ
    • Unsupported: ÃÕãõŇŘŠňřšǸǹŃńŮů

    U.S. Extended

    • Supported: ÄËÏÖÜŸäëïöüÿÁÉÍÓÚáéíóúÀÈÌÒÙàèìòùÂÊÎÔÛâêîôûÃÕÑãõñŃńǸǹŇňŘřŠšÅåŮů
    • Unsupported: [nothing]