Lpc*_*ark 0 mouse events mouseevent node.js
我想知道在 nodejs 中我们是否可以获得鼠标位置。这是一个如此简单的快速问题,但我找不到是或否的答案。
所以简单的问题是我可以使用本机节点获取鼠标位置吗?
对于这个问题,最好不要将节点视为服务器端语言。
Node可以在任何地方运行。因此节点 webkit。这是一个 webkit 应用程序,但它是在后端运行的节点。
我只想跟踪鼠标。问题是如果鼠标离开页面,它现在无法跟踪。但我也想在窗口外跟踪它。
我一直在研究一个用于获取鼠标位置的模块RobotJS。
示例代码:
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();
Run Code Online (Sandbox Code Playgroud)