I want just move the mouse to a specific location relative to my App Window.
我只想将鼠标移动到相对于我的应用程序窗口的特定位置。
I don't find a way to achieve this behavior, is that even possible?
我找不到实现这种行为的方法,甚至可能吗?
2 个解决方案
#1
2
Check out RobotJS, it should do just fine in your case. From its docs:
看看RobotJS,你应该做得很好。从它的文档:
// Move the mouse across the screen as a sine wave.
var robot = require("robotjs");
// Speed up the mouse.
robot.setMouseDelay(2);
var twoPI = Math.PI * 2.0;
var screenSize = robot.getScreenSize();
var height = (screenSize.height / 2) - 10;
var width = screenSize.width;
for (var x = 0; x < width; x++)
{
y = height * Math.sin((twoPI * x) / width) + height;
robot.moveMouse(x, y);
}
#2
0
See WebContents.prototype.sendInputEvent
Example:
remote.getCurrentWebContents().sendInputEvent({type: 'mouseMove', x: 10, y: 10})
#1
2
Check out RobotJS, it should do just fine in your case. From its docs:
看看RobotJS,你应该做得很好。从它的文档:
// Move the mouse across the screen as a sine wave.
var robot = require("robotjs");
// Speed up the mouse.
robot.setMouseDelay(2);
var twoPI = Math.PI * 2.0;
var screenSize = robot.getScreenSize();
var height = (screenSize.height / 2) - 10;
var width = screenSize.width;
for (var x = 0; x < width; x++)
{
y = height * Math.sin((twoPI * x) / width) + height;
robot.moveMouse(x, y);
}
#2
0
See WebContents.prototype.sendInputEvent
Example:
remote.getCurrentWebContents().sendInputEvent({type: 'mouseMove', x: 10, y: 10})