Skip to content

RobotJS

Node.js library for controlling the mouse and keyboard and reading the screen.

Stars
12.8k
Forks
1k
Licence
MIT
Language
C
Last update
13 days ago
Type
Library

What it is

RobotJS is a Node.js library that lets a script move the mouse, press keys, type text, read pixel colors, and capture or search the screen. It is useful for automating desktop tasks that have no API. The README says it supports Mac, Windows, and Linux, and it is described as a work in progress whose functions could change before version 1.0.0.

  • Type a fixed string and press Enter with a short script
  • Move the mouse along a path or click at a position found by image search
  • Read the color of the pixel under the mouse
  • Capture a region of the screen and save it as an image

Great for

  • Developers who want to script repetitive desktop tasks in JavaScript
  • People automating apps that expose no API, by clicking and typing
  • Node.js or Electron developers who need simple mouse and keyboard control
  • Users who need to find an image or color on screen and act on it

Not ideal for

  • Anyone needing global hotkeys, since the FAQ says RobotJS does not currently support them
  • Anyone needing window management, which the README lists only as a possible future feature
  • Users who need a stable API, since the README warns functions may change before 1.0.0
  • Users on platforms outside Mac, Windows, and Linux, since the README does not describe support for others
Step-by-step guide: how to use RobotJSInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js (README links to nodejs.org for install) · npm · For source builds: Python 3, make, and a C/C++ compiler on Linux; Visual Studio C++ toolchain on Windows; Xcode Command Line Tools on macOS

    Install with npm

    npm install robotjs
  2. 2

    Run it

    • Install Node.js and npm if they are not already present
    • Run npm install robotjs in your project folder
    • Create a script that requires robotjs, for example the README keyboard example
    • Run the script with node and check the result on screen
  3. 3

    Get the most out of it

    • Use robot.setMouseDelay to speed up or slow down mouse movement
    • Use robot.screen.capture and findImage for image-based automation
    • On macOS, check getAccessibilityPermission and getScreenCapturePermission before running automation
    • Use robot.getDisplays to target a specific monitor for capture
    • Check robot.image.supportsPNG at runtime if you need PNG support in a source build

Downloads

Strengths

  • Simple, short API for mouse, keyboard, and screen tasks
  • Prebuilt binaries are published for Linux, macOS, and Windows on x64 and arm64
  • Documented on a dedicated docs site and a wiki with examples

Trade-offs

  • README states the API is a work in progress and may change before 1.0.0
  • Building from source needs native toolchains such as Visual Studio C++, Xcode tools, or GCC plus libxtst-dev on Linux
  • The FAQ says it lacks global hotkeys and window management

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.