gitmyhub

robotjs

C ★ 13k updated 5d ago

Node.js Desktop Automation.

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.

JavaScriptNode.jsCnpmsetup: moderatecomplexity 2/5

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.

Where it fits