Giter Site home page Giter Site logo

robot / robot-js Goto Github PK

View Code? Open in Web Editor NEW
195.0 11.0 23.0 471 KB

Native system automation for node.js

Home Page: http://getrobot.net

License: zlib License

JavaScript 75.04% C++ 24.05% Python 0.91%
native cross-platform c-plus-plus desktop system automation framework linux macos windows

robot-js's Introduction

ROBOT

Native System Automation for Node

Built with Robot Robot 2.0.0 NPM 2.0.0 Node 0.12 - 9 Docs API ZLIB License

Introducing Robot for Node, a library aimed at facilitating the development of system automation software for the purposes of test automation, self-running demos, and other applications. The library works by abstracting away all platform-specific differences into a single, robust API compatible with most desktop operating systems. Functionality ranges from basic keyboard and mouse automation to advanced process manipulation capabilities. It has everything you need to take full control of your system. Visit the Homepage for more information.

npm install robot-js

robot-js's People

Contributors

dkrutsko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robot-js's Issues

Incompatible with node v10 (NODE_MODULE_VERSION=64)

The API for Node 10 has changed, and the existing robot-js bindings do not compile against it correctly. Testing with Node v10.6.0 on Linux, I get this set of errors:

In file included from ../src/NodeImage.h:15:0,
                 from ../src/NodeImage.cc:14:
../src/NodeImage.cc: In static member function ‘static void ImageWrap::GetPixel(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/NodeCommon.h:68:47: error: no matching function for call to ‘v8::Function::NewInstance(int, v8::Local<v8::Value> [4])’
    (isolate, JsColor)->NewInstance (4, _jsArgs) \
                                               ^
../src/NodeCommon.h:112:54: note: in definition of macro ‘RETURN’
 #define RETURN( value ) { args.GetReturnValue().Set (value); return; }
                                                      ^
../src/NodeCommon.h:125:10: note: in expansion of macro ‘NEW_COLOR’
  RETURN (NEW_COLOR (r, g, b, a));
          ^
../src/NodeImage.cc:112:2: note: in expansion of macro ‘RETURN_COLOR’
  RETURN_COLOR (color.R, color.G,
  ^
../src/NodeCommon.h:68:47: note: candidates are:
    (isolate, JsColor)->NewInstance (4, _jsArgs) \
                                               ^
../src/NodeCommon.h:112:54: note: in definition of macro ‘RETURN’
 #define RETURN( value ) { args.GetReturnValue().Set (value); return; }
                                                      ^
../src/NodeCommon.h:125:10: note: in expansion of macro ‘NEW_COLOR’
  RETURN (NEW_COLOR (r, g, b, a));
          ^
../src/NodeImage.cc:112:2: note: in expansion of macro ‘RETURN_COLOR’
  RETURN_COLOR (color.R, color.G,
  ^
In file included from /home/travis/.node-gyp/10.6.0/include/node/node.h:63:0,
                 from /home/travis/.node-gyp/10.6.0/include/node/node_buffer.h:25,
                 from ../src/NodeCommon.h:16,
                 from ../src/NodeImage.h:15,
                 from ../src/NodeImage.cc:14:
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3911:44: note: v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>, int, v8::Local<v8::Value>*) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                            ^
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3911:44: note:   candidate expects 3 arguments, 2 provided
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3914:44: note: v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                            ^
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3914:44: note:   candidate expects 1 argument, 2 provided
../src/NodeImage.cc: In static member function ‘static void ImageWrap::New(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/NodeImage.cc:206:37: error: no matching function for call to ‘v8::Function::NewInstance(int, v8::Local<v8::Value> [4])’
       _jsArgs[1] = args[1], _jsArgs));
                                     ^
../src/NodeImage.cc:206:37: note: candidates are:
In file included from /home/travis/.node-gyp/10.6.0/include/node/node.h:63:0,
                 from /home/travis/.node-gyp/10.6.0/include/node/node_buffer.h:25,
                 from ../src/NodeCommon.h:16,
                 from ../src/NodeImage.h:15,
                 from ../src/NodeImage.cc:14:
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3911:44: note: v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>, int, v8::Local<v8::Value>*) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                            ^
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3911:44: note:   candidate expects 3 arguments, 2 provided
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3914:44: note: v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                            ^
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3914:44: note:   candidate expects 1 argument, 2 provided
In file included from ../src/NodeImage.h:15:0,
                 from ../src/NodeImage.cc:14:
../src/NodeImage.cc:223:35: error: no matching function for call to ‘v8::Function::NewInstance(int, v8::Local<v8::Value> [4])’
     _jsArgs[1] = args[1], _jsArgs)));
                                   ^
../src/NodeCommon.h:112:54: note: in definition of macro ‘RETURN’
 #define RETURN( value ) { args.GetReturnValue().Set (value); return; }
                                                      ^
../src/NodeImage.cc:223:35: note: candidates are:
     _jsArgs[1] = args[1], _jsArgs)));
                                   ^
../src/NodeCommon.h:112:54: note: in definition of macro ‘RETURN’
 #define RETURN( value ) { args.GetReturnValue().Set (value); return; }
                                                      ^
In file included from /home/travis/.node-gyp/10.6.0/include/node/node.h:63:0,
                 from /home/travis/.node-gyp/10.6.0/include/node/node_buffer.h:25,
                 from ../src/NodeCommon.h:16,
                 from ../src/NodeImage.h:15,
                 from ../src/NodeImage.cc:14:
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3911:44: note: v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>, int, v8::Local<v8::Value>*) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                            ^
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3911:44: note:   candidate expects 3 arguments, 2 provided
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3914:44: note: v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
                                            ^
/home/travis/.node-gyp/10.6.0/include/node/v8.h:3914:44: note:   candidate expects 1 argument, 2 provided

In the long-term, I'm sure we will want to rework this module to use NAN or N-API, but in the short-term, I wonder if there is a way to adjust the macros so as to support ABI 64...

Cannot set autoDelay

Hey, trying to use robot-js in an Electron app with Angular. I've linked the service below and the problem is that i can't seem to set the autoDelay. Everything else works, i can use this.keyboard().click() without problem but i can't seem to set autoDelay, i've tried with everything i can think of now, examples below.

https://github.com/viktorgullmark/exile-party/blob/features/robot-js/ExilePartyClient/src/app/shared/providers/robot.service.ts

const range = this.electronService.robot.Range(5, 10);
this.keyboard().autoDelay.min = 10;
this.keyboard().autoDelay.max = 30;
this.keyboard().autoDelay = range;

Add integrity checks when downloading pre-compiled binaries

Currently, installing robot-js via NPM may be susceptible to man-in-the-middle attacks. This is due to the pre-compiled binaries being downloaded over HTTP instead of HTTPS. Unfortunately, because these binaries are hosted on GitHub, it's not easy to switch to HTTPS. A possible solution would be to perform a file integrity check after downloading the file to ensure that no tampering has taken place.

In the meantime, if security is a huge concern, download the binaries directly from GitHub or compile them manually using the guide available here.

Accessing Thread Local Storage

I'm looking for a way to access the TLS for a process from node, and didn't see anything in the API about it - maybe I just wasn't looking in the right place or there is some different terminology used, but the ability to access TLS seems like it would fit well with some of the other memory access functions robot-js provides.

The following SO question has a code snippet showing how it works on Windows. Linux and OS X seem to have their own variants.
http://reverseengineering.stackexchange.com/questions/3139/how-can-i-find-the-thread-local-storage-tls-of-a-windows-process-thread

Press multiple keys at the same time.

I am working on a project where I need to press multiple keys at the same time. I have tried things like.

  keyboard.press(robot.KEY_W);
  keyboard.click(robot.KEY_S);
  keyboard.release(robot.KEY_W);

It doesn't hit them at the same time, I also fiddled with the autoDelay but this made the inputs unreliable. Is there a way to archive this? Any help will be much appreciated.

Add Node.js 6.0 support

The Node foundation released Node 6.0 today. Need to add support for this new major version.

Add version information to windows binary

Windows supports the ability to compile version information as part of DLLs and executables. Since native Node modules are simple DLL files, version information could be included as part of the distribution. This would make identifying versions of modules simpler. The language neutral version information would include:

ProductName      = robot-js
FileVersion      = x.x.x.[modules_version]
RobotVersion     = x.x.x.0
CompanyName      = Robot Developers
OriginalFilename = [platform]-[arch]-[modules_version].node 

All input calls fails after Windows.SetActive

After calling robot.Window.setActive, none of the input calls (robot.Mouse.setPos, mouse.click, keyboard.click) would work.

If I comment out the setActive line, everything works as expected. SetActive itself works because the window was brought to the front, but any subsequent input events would silently fail.

System: Windows 10 x64, Node JS v6.3.1 using precompiled robot binary.

Here's my code:

var robot = require ("robot-js");
const data_memory_xy = robot.Point(310,493)

var list = robot.Window.getList (".*STVP.*")
if (list.length === 0) {
	console.log("Please run STVP")
	process.exit(0)
}
var win = list[0]
robot.Window.setActive(win)

var mouse = robot.Mouse();
robot.Mouse.setPos(data_memory_xy)
mouse.click(robot.BUTTON_LEFT);

var keyboard = robot.Keyboard();
keyboard.click("123");

Get current cursor state

This is probably more of a feature request but is there any way to get the current mouse state? (Ie. Pointer, hand, text, etc)

I'm creating a remote desktop app and would like to be able to match the client cursor.

Also is there any way to tell if your currently active on a typable area so I can trigger the mobile keyboard?

robot-js binaries failed to install

UPDATE:
If you're having the same problem, stop reading and just use this package instead.
https://github.com/octalmage/robotjs

npm i robot-js --save

> [email protected] install /Users/qashto/Documents/web/qodemate/node_modules/robot-js
> node Native/Install.js

ERROR: robot-js binaries failed to install. You will need to install them manually, see http://getrobot.net/docs/node.html for more info. Reason: bad response (404) Not Found

+ [email protected]
updated 1 package in 3.619s

Trying to update robot-js because I just installed node v8.9.1. I get this error, how do I install the binaries manually?

Robot-js 2.0 ship list

  • #43, #44: Updated all copyright headers to 2018
  • #5, #16, #26, #14: Added support for Node 7, 8 & 9
  • #13, #19: Fixed and updated the README file
  • #6, #22: Added integrity checks for binary files (Adv-201)
  • #28, #30: Added NPM and Yarn lock files
  • #32, #35: Reorganized the entire project structure
    • #4: Replaced the build pipeline with node-gyp
    • #36: Added version info to Windows binary
    • #37: Added basic automated testing support
    • #2: Resolved issues surrounding Electron
  • #46, #47: Removed support for Windows Vista (why?)
  • #50, #53: Copy Windows PDB files during compilation
  • #25, #54: Added experimental support for Raspberry Pi
    • Precompiled binaries for linux on arm are provided

Gets no windows on OSX

const robot = require('robot-js');
const list = robot.Window.getList('.*');
console.log(list.length);

Output is always 0.
Am I doing something wrong?

Add project files for other editors

With the advent of new cross-platform editors on the market, it might be nice to create project files for each of them in order to improve development experience. Some editors which might be nice to include support for are: Sublime Text, Visual Studio Code, Atom and Brackets. Other, larger, editors like XCode, Intel, CodeBlocks, Netbeans, Eclipse, CLion and others are also worth investigating but we have to be careful as to not over-pollute the project with project files (like Visual Studio already does).

Update support for Node.js ^7

A new Node.js major release is now available and with that, a new modules version (51). Robot-js needs to be patched and tested with this new version.

DISPLAY other than :0.0?

Fix is like this, but I cannot find the xdisplay.c in master, so how does node-gyp or such generate that file?

                char* display = getenv("DISPLAY");
                if (display == NULL)
                  display = displayName;
		mainDisplay = XOpenDisplay(display);

Electron

Ideally i need to get this working within electron.

There's documentation about this here: http://electron.atom.io/docs/v0.37.8/tutorial/using-native-node-modules/

And a package which takes care of most of it: https://github.com/electron/electron-rebuild for most modules. We're missing a bindings.gyp file which is what electron-rebuild requires. Instead you've got a manual build process going on.

I'm guessing the easiest way here is to manually build electron binaries and include them in the pre-built repo. I'll look into adding stuff into the makefiles etc.

keyboard hold key sticky

Hello. If I press a key, wait some time and release, I have no "sticky" effect like aaaaaaaaaaaaaaaaaa:

var kb = new robot.Keyboard();
kb.press(robot.KEY_A);
robot.Timer.sleep(2000);
kb.release(robot.KEY_A);
kb.click(robot.KEY_BACKSPACE);

I have tried setTimeout also, but no luck

keyboard type

Hello! I need to change the layout of the keyboard for the project I'm currently working.
I need a Spanish keyboard. Would it be possible?

Thanks in advance.

request raspbian

Hi there,

is there any chance robot-js will be available on the raspberry pi with raspbian?

thanks in advance
sincerely Matthias

Improve automated test cases

Automated testing (types and timer) should be accessible via npm scripts form (i.e. npm test). In addition, test cases should not require user input upon completion and should set the proper exit code on failure.

Slight install script improvements

The install script should be a bit better with error messages now that node-gyp is fully integrated. In addition to fixing the error messages, maybe include a dependency to a console coloring package for a nicer presentation.

Update project node version numbers

The default node version (and module) numbers need to be updated in the project files. And instead of using 0.12, we should use the latest available version of Node. For more information, see this and this.

How can I make press key not described?

Hi.

I want to press the key operators in numberpad like ' + * - ...
But I cannot find what keyword points that key.
Is another way to make press that key?

Thanks.
(sorry for my English)

keyboard not working in games

Hey there.
Dispatching keys is not working in games for me.
keyboard.click(robot.KEY_Q); for example is not doing anything when using it in a game window, it works when trying to dispatch it to a text-field though (even works with the ingame chat of the game).

Any suggestion or a fix?

Suprisingly, I've done something similar before with Java's Robot class and it worked just fine.

Add eslint to the project

The JavaScript portion of the code should be linted through eslint. This will require adding an .eslintrc.json file and setting up some sort of NPM script to run it. Alternatively, this could also be implemented as part of the testing framework.

Project description is misleading

This project still fails to install with the latest version of node LTS 8.9.3. It has been over two months since this project has been incompatible with node LTS. Please do not claim to support node.js in this project's description if LTS "updates" will continue to not be supported in the future, this is the bare minimum of support required for a project to claim it supports node. Preparation to support 8.9.x should have taken place before it was made the LTS version, this issue #26 was first brought up in August! This project's description is misleading to developers as long as LTS compatibility is not maintained. I know this is an open source project but time must be set aside to maintain a project with a constantly evolving language like node.js. It's obvious that incredible amounts of works went into this project and it's one of my favorite packages for node.js so please don't let it go to waste by maintaining it unreliably. When developers depend on a package and build whole apps around their functionality there can't be gaps in coverage for the LTS versions of node. I doubt I am the only dev that wants to use this library to make client-side local apps and needs prebuilt binaries to be available. Don't let trying to reach big milestones, implementing other features, or even fixing bugs get in the way of crucial updates.

Include PDB files in compilation

On windows, PDB files can be used to help debug potential issues with the library. As such, they should be copied over to the lib folder as part of the compilation process as well as offered for download when using the prebuilt libraries. Since they're a bit big, I don't think they should be downloaded automatically through the install script (if supported).

extending classes with ES6 syntax

There is unable to extend classes

var robot = require('robot-js');
class Window extends robot.Window {
  constructor(hwnd) {
    super(hwnd);
    this.newProperty = 'hello';
  }
  newFeature(){}
}

var wnd = new Window();
wnd.newProperty; // 'hello' !!! this is weird
wnd.newFeature(); // TypeError: newFeature in not a function
wnd instanceof Window // false
wnd instanceof robot.Window // true

:(

Custom clipboard formats and binary data

I've been working on a fork of Robot-JS, trying to build support for native clipboard access. This includes the ability to read / write custom data formats and binary data (instead of just Text and Images).
I'd like to know if these changes would be a welcome addition to the project, and if so, I'd like to make sure I'm headed in a good direction before continuing work and creating a PR. I'd also like to make sure I'm not duplicating any other potential work.
So here's my first question: Should I be modifying the /Native/ code in this repo? Its hard to tell if the Native code is just copied from robot or if it's developed independently?

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.