2015-06-20 86 views
0

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

有什么办法呢?我已经搜索了现有的软件包,但没有找到任何...

+0

,似乎有关 - http://stackoverflow.com/questions/22695122/move-mouse-cursor-with-node-js – Malki

回答

2

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(); 
发现这个问题