如何在 NodeJS 中使用 ffi 单击?
How can I click using ffi in NodeJS?
我正在为 Windows 创建一个机器人。移动鼠标,这是我目前的代码:
var ffi = require('ffi'),
user32 = ffi.Library('user32', {
'SetCursorPos': ['long', ['long', 'long']]
});;
user32.SetCursorPos(100,100);
我需要一个使用 ffi(或任何其他方式)点击给定坐标的函数,例如
click(100,100);
这对我有用:
var ffi = require('ffi'),
user32 = ffi.Library('user32', {
'SetCursorPos': ['long', ['long', 'long']],
'mouse_event': ['void', ['int', 'int', 'int', 'int', 'int']]
});;
MOUSEEVENTF_LEFTDOWN = 2;
MOUSEEVENTF_LEFTUP = 4;
user32.SetCursorPos(3, 3);
user32.mouse_event(MOUSEEVENTF_LEFTDOWN, 0 ,0 ,0 ,0);
user32.mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
我正在为 Windows 创建一个机器人。移动鼠标,这是我目前的代码:
var ffi = require('ffi'),
user32 = ffi.Library('user32', {
'SetCursorPos': ['long', ['long', 'long']]
});;
user32.SetCursorPos(100,100);
我需要一个使用 ffi(或任何其他方式)点击给定坐标的函数,例如
click(100,100);
这对我有用:
var ffi = require('ffi'),
user32 = ffi.Library('user32', {
'SetCursorPos': ['long', ['long', 'long']],
'mouse_event': ['void', ['int', 'int', 'int', 'int', 'int']]
});;
MOUSEEVENTF_LEFTDOWN = 2;
MOUSEEVENTF_LEFTUP = 4;
user32.SetCursorPos(3, 3);
user32.mouse_event(MOUSEEVENTF_LEFTDOWN, 0 ,0 ,0 ,0);
user32.mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);