• Stars
    star
    12,054
  • Rank 2,556 (Top 0.06 %)
  • Language
    C
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node.js Desktop Automation.

Node.js Desktop Automation. Control the mouse, keyboard, and read the screen.

RobotJS supports Mac, Windows, and Linux.

This is a work in progress so the exported functions could change at any time before the first stable release (1.0.0). Ideas?

Check out some of the cool things people are making with RobotJS! Have your own rad RobotJS project? Feel free to add it!

Contents

Installation

Install RobotJS using npm:

npm install robotjs

It's that easy! npm will download one of the prebuilt binaries for your OS.

You can get npm here if you don't have it installed.

If you need to build RobotJS, see the building section. Instructions for Electron.

Examples

// Move the mouse across the screen as a sine wave.
var robot = require("robotjs");

// Speed up the mouse.
robot.setMouseDelay(2);

var twoPI = Math.PI * 2.0;
var screenSize = robot.getScreenSize();
var height = (screenSize.height / 2) - 10;
var width = screenSize.width;

for (var x = 0; x < width; x++)
{
	y = height * Math.sin((twoPI * x) / width) + height;
	robot.moveMouse(x, y);
}
// Type "Hello World" then press enter.
var robot = require("robotjs");

// Type "Hello World".
robot.typeString("Hello World");

// Press enter.
robot.keyTap("enter");
// Get pixel color under the mouse.
var robot = require("robotjs");

// Get mouse position.
var mouse = robot.getMousePos();

// Get pixel color in hex format.
var hex = robot.getPixelColor(mouse.x, mouse.y);
console.log("#" + hex + " at x:" + mouse.x + " y:" + mouse.y);

Read the Wiki for more information!

The RobotJS API is hosted at https://robotjs.io/docs/syntax.

Building

Please ensure you have the required dependencies before installing:

  • Windows
    • windows-build-tools npm package (npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe)
  • Mac
    • Xcode Command Line Tools.
  • Linux
    • Python (v2.7 recommended, v3.x.x is not supported).
    • make.
    • A C/C++ compiler like GCC.
    • libxtst-dev and libpng++-dev (sudo apt-get install libxtst-dev libpng++-dev).

Install node-gyp using npm:

npm install -g node-gyp

Then build:

node-gyp rebuild

See the node-gyp readme for more details.

Plans

  • √ Control the mouse by changing the mouse position, left/right clicking, and dragging.
  • √ Control the keyboard by pressing keys, holding keys down, and typing words.
  • √ Read pixel color from the screen and capture the screen.
  • Find an image on screen, read pixels from an image.
  • Possibly include window management?

Progress

Module Status Notes
Mouse 100% All planned features implemented.
Keyboard 100% All planned features implemented.
Screen 85% Image search, pixel search.
Bitmap 0% Saving/opening, png support.

FAQ

Does RobotJS support global hotkeys?

Not currently, and I don't know if it ever will. I personally use Electron/NW.js for global hotkeys, and this works well. Later on I might add hotkey support or create a separate module. See #55 for details.

Can I take a screenshot with RobotJS?

Soon! This is a bit more complicated than the rest of the features, so I saved it for last. Luckily the code is already there, I just need to write the bindings, and I've already started. Subscribe to #13 for updates.

Why is <insert key> missing from the keyboard functions?

We've been implementing keys as we need them. Feel free to create an issue or submit a pull request!

How about multi-monitor support?

The library doesn't have explicit multi-monitor support, so anything that works is kind of on accident. Subscribe to #88 for updates.

For any other questions please submit an issue.

Story

I'm a huge fan of AutoHotkey, and I've used it for a very long time. AutoHotkey is great for automation and it can do a bunch of things that are very difficult in other languages. For example, it's imagesearch and pixel related functions are hard to reproduce on Mac, especially in scripting languages. These functions are great for automating apps that can't be automated like Netflix. This has never been a big deal since I've always used Windows at work, but for the past few years I've been using Mac exclusively.

I like AutoHotkey, but I like Node.js more. By developing RobotJS I get an AutoHotkey replacement on Mac (finally!), and I get to use my favorite language.

TLDR: There's nothing like AutoHotkey on Mac, so I'm making it.

License

MIT

Based on autopy. Maintained by Jason Stallings.

More Repositories

1

mDesktop

mDesktop is a lightweight application that allows the user to utilize multiple virtual desktops.
AutoHotkey
236
star
2

googlehacks

A compact utility for several Google hacks.
HTML
187
star
3

active-window

Get active window title in Node.js.
JavaScript
159
star
4

gatsby-plugin-sentry

Gatsby plugin to add Sentry error tracking to your site.
JavaScript
48
star
5

minum

A new minimal web browsing experience.
JavaScript
42
star
6

Marknote

Markdown Note Taking.
HTML
35
star
7

HotGifs

Hot Gifs is the quickest way to find great gifs on your computer.
JavaScript
33
star
8

pixelcolor

Get pixel color from screen.
JavaScript
30
star
9

Ninja-Browser

A browser for ninjas?
JavaScript
22
star
10

multisig.money

TypeScript
18
star
11

mousecontrol

Control the mouse in the browser using JavaScript.
JavaScript
13
star
12

ZenApp

Zendesk Desktop Application.
HTML
13
star
13

lull

Automatically mute Hulu ads.
JavaScript
13
star
14

robotjs.io

The official site for RobotJS.
HTML
12
star
15

CVS-Bangers

A website dedicated to the greatest mix of all time.
JavaScript
10
star
16

github-readme

Embed readme files in pages/posts.
PHP
10
star
17

live-logs

Display live traffic on a map.
JavaScript
10
star
18

Pass

Pass a window to a friend.
JavaScript
9
star
19

targetpractice

Test UI automation tools using Node.js.
JavaScript
9
star
20

ExternalScreen

Multi-screen application scenarios for Cordova projects.
Objective-C
9
star
21

Notepad

Windows Notepad for Mac.
CSS
8
star
22

AirHorn

Air Horn for WordPress backend.
PHP
8
star
23

LastGoogle

Mobile Substrate tweak to log songs played using the Google Play Music iOS app.
Logos
8
star
24

alarm

The most insane alarm clock you've ever seen.
JavaScript
8
star
25

insultgenerator

Node.js module that pulls random insults from insultgenerator.org.
JavaScript
8
star
26

js-error-log

WordPress plugin to catch and log JavaScript errors.
PHP
8
star
27

TV

Watch movies with your friends!
HTML
8
star
28

Fire-TV-Remote

Apple Watch Fire TV remote
Swift
7
star
29

speedbar

Internet speed in your menu bar.
JavaScript
6
star
30

jason.stallin.gs

My personal website.
JavaScript
6
star
31

WordPress.org-Also-Viewing

See when another person is viewing the same post.
JavaScript
6
star
32

hackshell

A terminal emulator for hackers.
JavaScript
5
star
33

GammaGamma

F.lux clone written in AutoHotkey.
AutoHotkey
5
star
34

StageKit

Control Rockband StageKit with AutoHotkey.
AutoHotkey
5
star
35

react-github-widget

A good looking GitHub repository widget to add to your website.
JavaScript
5
star
36

githubhop

Uses GH Archive to create Timehop for GitHub.
Go
5
star
37

Screenlr

Screen capture for Tumblr.
JavaScript
4
star
38

NoteTray

Notes in your system tray (Windows).
AutoHotkey
4
star
39

PebbleFlix-Server

Desktop server for PebbleFlix.
JavaScript
4
star
40

generator-easyelectron

Yeoman generator for a basic Electron app.
JavaScript
4
star
41

appletv-autoplay

Tired of the "are you still watching" prompt?
JavaScript
4
star
42

CastList

Chromecast URL Playlist.
JavaScript
4
star
43

blogchain

Ethereum backed blog platform.
JavaScript
4
star
44

jesus.codes

HTML
4
star
45

wpenginesaver

WP Engine Screensaver
HTML
4
star
46

rover

Terra development suite
Rust
3
star
47

zerohero

Easy cross platform zeroconf microservice (Service Discovery)
JavaScript
3
star
48

champagne-airdrop

Rust
3
star
49

garbagecal

1 minute before a meeting garbagecal will minimize all windows and open the Zoom.us link for the meeting.
JavaScript
3
star
50

PrettyWall

Do you like pretty colors?
JavaScript
3
star
51

terra-ibc

TypeScript
3
star
52

marketswap.money

TypeScript
3
star
53

dfinity-guestbook

A retro 90's style Web3.0 guestbook built on DFINITY.
JavaScript
3
star
54

Tango

C#
3
star
55

phptomoment

Convert PHP's date format to a Moment.js compatible format.
JavaScript
3
star
56

html-webpack-root-plugin

HTML Webpack plugin that adds a tag to the generated HTML for a mount point.
JavaScript
3
star
57

terra-blocklist

Rust
2
star
58

Dark-Edit

Edit text in a distraction free environment.
AutoHotkey
2
star
59

terra-indexer

JavaScript
2
star
60

firetv-autoplay

Tired of the "are you still watching" prompt?
JavaScript
2
star
61

meep-old

Image board implemented as a blockchain. Possibly the worst idea ever!
TypeScript
2
star
62

shcoffee

Easily use CoffeeScript for global ShellJS scripts without .coffee extension.
JavaScript
2
star
63

Chimera

Split screen browser with optional mobile emulation.
JavaScript
2
star
64

propjs

Check global DNS propagation.
JavaScript
2
star
65

agile-alarm

JavaScript
2
star
66

langs

Playing with different languages.
Clojure
2
star
67

terra-jump-insane-counter

Rust
2
star
68

wp-travis

WordPress plugin to trigger a TravisCI build when a new post is published.
PHP
2
star
69

PebbleFlix

Control Netflix with your watch (Pebble).
C
2
star
70

TheWall

A different kind of Window Manager
AutoHotkey
2
star
71

FiftyFifty

Mac OS X window management
JavaScript
2
star
72

gifwars

JavaScript
2
star
73

cw721-metadata-onchain

Rust
2
star
74

TiddlyPad

TiddlyWiki container.
JavaScript
2
star
75

Showcaser

Put applications on a white backdrop for screenshots/videos.
AutoHotkey
2
star
76

dfinity-ic-cafe

JavaScript
2
star
77

timechainsaver

macOS screensaver for Ordinals Inscription #144377 from the Genesis Series #0 Timechain collection.
HTML
2
star
78

whatshappening

What's making Austin suck this weekend?
JavaScript
2
star
79

FreeWindowHider

Hide windows based on rules, using a hotkey.
AutoHotkey
2
star
80

react-lastfm-widget

Display the most recent Last.fm scrobble for a user.
OCaml
2
star
81

dailynote

JavaScript
2
star
82

nerdtalk

Talk to a random nerd from your terminal.
JavaScript
2
star
83

xAlt

Xfce like window management for Windows.
AutoHotkey
2
star
84

generator-easynwjs

Very simple Yeoman nw.js app generator.
JavaScript
2
star
85

bbdraw

PWA to practice drawing on a mobile device
JavaScript
2
star
86

PokemonPicker

Randomized Pokemon picker for Pokemon Stadium.
JavaScript
2
star
87

YoPress

Yo your subscribers when you publish a new post!
PHP
2
star
88

noidle

Don't let your computer or applications sleep.
JavaScript
2
star
89

generator-flathtml

A Yeoman generator for a simple HTML file.
JavaScript
2
star
90

closeWindow

Close the active window.
JavaScript
2
star
91

FreeLogger

Open source keylogger.
AutoHotkey
2
star
92

EasyDebug

Easily disable plugins and switch to a default theme using query strings.
PHP
2
star
93

ngrokrock

JavaScript
2
star
94

Cosmonaut

Generate static versions of your dynamic sites.
JavaScript
1
star
95

lodoop

Automatically exported from code.google.com/p/lodoop
AutoHotkey
1
star
96

all

TypeScript
1
star
97

chainshot-demo

Rust
1
star
98

meep

TypeScript
1
star
99

Vlock

YouTube Alarm Clock.
HTML
1
star
100

twitchplayswordpress

An experiment using Twitch.tv and WordPress.
JavaScript
1
star