explaingit

octalmage/robotjs

12,734CAudience · developerComplexity · 2/5LicenseSetup · moderate

TLDR

A Node.js library for controlling the mouse, keyboard, and screen from JavaScript on Mac, Windows, and Linux. Write automation scripts that click, type, and read pixel colors, like AutoHotkey but in JavaScript.

Mindmap

mindmap
  root((repo))
    What it does
      Control mouse
      Send keyboard input
      Read pixel colors
    Platform support
      macOS
      Windows
      Linux
    Tech
      Node.js API
      C native core
      OS input APIs
    Limitations
      No global hotkeys
      Limited multi-monitor
      Pre-1.0 API stability
    Install
      Single npm command
      Pre-built binaries
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Write a Node.js script that automates repetitive clicking or text entry in a desktop application.

USE CASE 2

Build a cross-platform macro tool that moves the mouse, presses keyboard shortcuts, and reacts based on a pixel color on screen.

USE CASE 3

Automate GUI interactions for a desktop app from JavaScript without needing a browser-based testing tool.

Tech stack

JavaScriptNode.jsCnpm

Getting it running

Difficulty · moderate Time to first run · 5min

Pre-built binaries cover common platforms, building from source on Linux requires Python, make, and X11 development headers.

MIT license, use freely for any purpose, including commercial projects, with no restrictions beyond keeping the copyright notice.

In plain English

RobotJS is a Node.js library that lets you control a computer's mouse and keyboard programmatically, and read pixel colors from the screen. If you want to write a script that moves the mouse, types text, clicks buttons, or reads what color is at a certain point on the screen, RobotJS gives you functions to do all of that from JavaScript code. It works on Mac, Windows, and Linux. The creator built it as a Mac-compatible replacement for AutoHotkey, a popular Windows-only automation tool. AutoHotkey lets power users script repetitive tasks and automate applications that do not have their own scripting support. RobotJS brings similar capabilities to JavaScript developers who want to write automation scripts in Node.js instead of a Windows-specific language. Installing it is a single npm command, and pre-built binaries are provided for common operating systems, so you typically do not need to compile anything yourself. If you do need to build from source, the README lists the platform-specific dependencies for Windows, Mac, and Linux. The library's core is written in C and hooks into each operating system's native input APIs. The mouse and keyboard modules are described as fully complete. The screen module, which lets you read pixel colors from anywhere on your display, is mostly done. A bitmap module for saving screenshots has not yet been built. Global hotkeys are not supported, and multi-monitor support is limited. This project pre-dates version 1.0, so the API could still change. The README notes it is a work in progress and the exported functions are not yet considered stable. It is released under the MIT license.

Copy-paste prompts

Prompt 1
Write a Node.js script using RobotJS that clicks at a specific screen coordinate every 5 seconds.
Prompt 2
How do I use RobotJS to type a string of text into whichever application currently has keyboard focus?
Prompt 3
Build a RobotJS automation that reads the pixel color at a set of screen coordinates and clicks a button only when the color matches a target value.
Prompt 4
Help me install RobotJS on macOS and write a script that moves the mouse in a smooth circular path across the screen.
Prompt 5
What are the current limitations of RobotJS, what can it not do, like global hotkeys or multi-monitor support?
Open on GitHub → Explain another repo

← octalmage on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.