Node.JS 向操作系统触发点击事件

Mal*_*lki 2 mouse operating-system mouseclick-event node.js

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

有什么可以做到的吗?我已经搜索了现有的软件包,但没有找到任何...

Jas*_*ngs 5

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();
Run Code Online (Sandbox Code Playgroud)