Reputation: 2385
I'm looking for a way to trigger a click event to the OS from a NodeJS application. All I need is to have control over x/y and mouse button.
Is there anything that does that? I've searched for existing packages but didn't find any...
Upvotes: 2
Views: 1659
Reputation: 1473
RobotJS does exactly what you want!
http://github.com/octalmage/robotjs
Try this code:
//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();
Upvotes: 5