Giter Site home page Giter Site logo

robotjs's Introduction

RobotJS

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!

npm version Build Status Ready Join the chat at https://gitter.im/octalmage/robotjs

Installing

Please make sure you have the required dependencies before installing:

  • Windows
    • Visual Studio 2013 (Express works fine).
    • Python (v2.7.3 recommended, v3.x.x is not supported).
  • 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).

Then install RobotJS using npm:

npm install robotjs

I plan on using node-pre-gyp to make this process easier.

Examples

Get the mouse position, move it, then click.

var robot = require("robotjs");

//Get the mouse position, returns an object with x and y. 
var mouse = robot.getMousePos();
console.log("Mouse is at x:" + mouse.x + " y:" + mouse.y);

//Move the mouse down by 100 pixels.
robot.moveMouse(mouse.x, mouse.y + 100);

//Left click!
robot.mouseClick();

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!

Building

node-gyp is required to build RobotJS.

Install node-gyp using npm:

npm install -g node-gyp

Then configure and build:

node-gyp configure
node-gyp build

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 image on screen, read pixels from image.
  • Possibly include window management?

Progress

Module Status Notes
Mouse 100% All planned features implemented.
Keyboard 100% All planned features implemented.
Screen 10% Screenshot, image search.

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.

robotjs's People

Contributors

octalmage avatar damonoehlman avatar drobati avatar spatializes avatar deltatiger avatar javiereguiluz avatar jub3i avatar hypercubed avatar qw3rtman avatar dthree avatar elemenofi avatar personsg avatar infiniteluke avatar

Watchers

zhangf avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.