0.7.3 • Published 6 years ago

simulate-native-click v0.7.3

Weekly downloads
6
License
ISC
Repository
github
Last release
6 years ago

simulate-native-click

Simple C++/WinApi addon that allow to simulate native clicks. TypeScript definitions inside.

Install

npm install simulate-native-click --save

Usage

var simulateClick = require("simulate-native-click");

let x = 100;
let y = 200;
simulateClick.left(hwnd, x, y);

x = 300;
y = 300;
simulateClick.right(hwnd, x, y);

simulateClick.getMousePosition(hwnd); // {x, y}
// position relative to window

simulateClick.getMousePosition(); // {x, y}
// global screen position returned if no hwnd provided

You can obtain HWND using winctl package https://www.npmjs.com/package/winctl

var win = winctl.GetActiveWindow();

let hwnd =  win.getHwnd();
let x = 100;
let y = 200;
simulateClick.left(hwnd, x, y);

You can also use it with electron:

let hwnd =  mainWindow.getNativeWindowHandle();
let x = 100;
let y = 200;
simulateClick.left(hwnd, x, y);