Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS native mouse and keyboard bindings [closed]

I've been looking for a native nodejs module that supports mouse and keyboard listening and execution

i found this.. https://npmjs.org/package/mouse but the source code looks like it only supports the browsers.

like image 539
bmatusiak Avatar asked Mar 05 '13 18:03

bmatusiak


2 Answers

I've been working on a module for sending mouse and keyboard events, RobotJS.

Example code:

var robot = require("robotjs");

//Get the mouse position, retuns 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();

Then for listening I use nw.js:

https://github.com/nwjs/nw.js/wiki/Shortcut

like image 122
Jason Stallings Avatar answered Sep 27 '22 21:09

Jason Stallings


You can wrap the Robot Class provided by Java for a cross platform solution using the node-java module.

Working example:

var java = require('java');

var Robot = java.import('java.awt.Robot');
var robot = new Robot();

robot.mouseMoveSync(0, 0);
like image 31
Jay Avatar answered Sep 27 '22 20:09

Jay