NodeJS本机鼠标和键盘绑定 [英] NodeJS native mouse and keyboard bindings
本文介绍了NodeJS本机鼠标和键盘绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找一个支持鼠标和键盘侦听和执行的本地nodejs模块
I've been looking for a native nodejs module that supports mouse and keyboard listening and execution
我发现了这个.. https://npmjs.org/package/mouse 但是源代码看起来只支持浏览器.
i found this.. https://npmjs.org/package/mouse but the source code looks like it only supports the browsers.
推荐答案
我一直在研究用于发送鼠标和键盘事件的模块, RobotJS .
I've been working on a module for sending mouse and keyboard events, 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();
然后使用nw.js进行监听:
Then for listening I use nw.js:
https://github.com/nwjs/nw.js/wiki/Shortcut
这篇关于NodeJS本机鼠标和键盘绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文