npm.io
0.7.3 • Published 8 years ago

simulate-native-click

Licence
ISC
Version
0.7.3
Deps
2
Size
8 kB
Vulns
0
Weekly
0
Stars
3
Install scriptsThis package runs scripts during installation (preinstall/install/postinstall)

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);

Keywords