Node.JS触发点击事件到OS

时间:2015-06-20 13:10:21

标签: node.js operating-system mouse mouseclick-event

我正在寻找一种从NodeJS应用程序触发操作系统点击事件的方法。我只需要控制x / y和鼠标按钮。

有什么可以做到的吗?我搜索了现有的套餐,但没有找到任何......

1 个答案:

答案 0 :(得分:4)

RobotJS完全符合您的要求!

http://github.com/octalmage/robotjs

试试这段代码:

//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();