Installations
npm install robotjs
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.16.3
NPM Version
6.9.0
Score
88.9
Supply Chain
97.2
Quality
72.5
Maintenance
100
Vulnerability
80.2
License
Releases
Contributors
Unable to fetch Contributors
Languages
C (84.46%)
C++ (7.67%)
JavaScript (4.94%)
Objective-C (2.43%)
Python (0.5%)
Developer
Download Statistics
Total Downloads
16,840,835
Last Day
3,286
Last Week
16,419
Last Month
110,461
Last Year
1,390,679
GitHub Statistics
12,463 Stars
651 Commits
978 Forks
206 Watching
29 Branches
50 Contributors
Bundle Size
647.00 B
Minified
344.00 B
Minified + Gzipped
Package Meta Information
Latest Version
0.6.0
Package Id
robotjs@0.6.0
Size
86.98 kB
NPM Version
6.9.0
Node Version
10.16.3
Publised On
08 Dec 2019
Total Downloads
Cumulative downloads
Total Downloads
16,840,835
Last day
-6.7%
3,286
Compared to previous day
Last week
-50.7%
16,419
Compared to previous week
Last month
-18.9%
110,461
Compared to previous month
Last year
-4.2%
1,390,679
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
4
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
Mouse
1// Move the mouse across the screen as a sine wave. 2var robot = require("robotjs"); 3 4// Speed up the mouse. 5robot.setMouseDelay(2); 6 7var twoPI = Math.PI * 2.0; 8var screenSize = robot.getScreenSize(); 9var height = (screenSize.height / 2) - 10; 10var width = screenSize.width; 11 12for (var x = 0; x < width; x++) 13{ 14 y = height * Math.sin((twoPI * x) / width) + height; 15 robot.moveMouse(x, y); 16}
Keyboard
1// Type "Hello World" then press enter. 2var robot = require("robotjs"); 3 4// Type "Hello World". 5robot.typeString("Hello World"); 6 7// Press enter. 8robot.keyTap("enter");
Screen
1// Get pixel color under the mouse. 2var robot = require("robotjs"); 3 4// Get mouse position. 5var mouse = robot.getMousePos(); 6 7// Get pixel color in hex format. 8var hex = robot.getPixelColor(mouse.x, mouse.y); 9console.log("#" + hex + " at x:" + mouse.x + " y:" + mouse.y);
Read the Wiki for more information!
API
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)
- windows-build-tools npm package (
- 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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
Found 7/8 approved changesets -- score normalized to 8
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v0.6.0 not signed: https://api.github.com/repos/octalmage/robotjs/releases/22060205
- Warn: release artifact v0.5.1 not signed: https://api.github.com/repos/octalmage/robotjs/releases/9925935
- Warn: release artifact v0.5.0 not signed: https://api.github.com/repos/octalmage/robotjs/releases/9925724
- Warn: release artifact v0.4.8 not signed: https://api.github.com/repos/octalmage/robotjs/releases/9848163
- Warn: release artifact v0.4.7 not signed: https://api.github.com/repos/octalmage/robotjs/releases/5873103
- Warn: release artifact v0.6.0 does not have provenance: https://api.github.com/repos/octalmage/robotjs/releases/22060205
- Warn: release artifact v0.5.1 does not have provenance: https://api.github.com/repos/octalmage/robotjs/releases/9925935
- Warn: release artifact v0.5.0 does not have provenance: https://api.github.com/repos/octalmage/robotjs/releases/9925724
- Warn: release artifact v0.4.8 does not have provenance: https://api.github.com/repos/octalmage/robotjs/releases/9848163
- Warn: release artifact v0.4.7 does not have provenance: https://api.github.com/repos/octalmage/robotjs/releases/5873103
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 29 are checked with a SAST tool
Reason
49 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r
- Warn: Project is vulnerable to: GHSA-rq8g-5pc5-wrhr
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-hr2v-3952-633q
- Warn: Project is vulnerable to: GHSA-8xwg-wv7v-4vqp
- Warn: Project is vulnerable to: GHSA-hv9c-qwqg-qj3v
- Warn: Project is vulnerable to: GHSA-6vrv-94jv-crrg
- Warn: Project is vulnerable to: GHSA-f9mq-jph6-9mhm
- Warn: Project is vulnerable to: GHSA-h9jc-284h-533g
- Warn: Project is vulnerable to: GHSA-m93v-9qjc-3g79
- Warn: Project is vulnerable to: GHSA-hvf8-h2qh-37m9
- Warn: Project is vulnerable to: GHSA-mpjm-v997-c4h4
- Warn: Project is vulnerable to: GHSA-3p22-ghq8-v749
- Warn: Project is vulnerable to: GHSA-77xc-hjv8-ww97
- Warn: Project is vulnerable to: GHSA-mq8j-3h7h-p8g7
- Warn: Project is vulnerable to: GHSA-p2jh-44qj-pf2v
- Warn: Project is vulnerable to: GHSA-p7v2-p9m8-qqg7
- Warn: Project is vulnerable to: GHSA-7x97-j373-85x5
- Warn: Project is vulnerable to: GHSA-7m48-wc93-9g85
- Warn: Project is vulnerable to: GHSA-qqvq-6xgj-jw8g
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-gxr4-xjj5-5px2
- Warn: Project is vulnerable to: GHSA-jpcq-cgw6-v4j6
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-wpg7-2c88-r8xv
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
2.5
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More