A node module to get information about the Windows mouse cursor, change its position and simulate clicks.
You must have Python and Visual Studio Community installed in order to install this package.
yarn add node-cursor
or
npm install node-cursor
import {getCursorPosition, setCursorPosition, sendCursorEvent, cursorEvents} from "node-cursor";
getCursorPosition();
//Return: { x: 0, y: 0 }
setCursorPosition({
x: 0,
y: 0
});
//Send mouse click at 0, 0
sendCursorEvent({
event: cursorEvents.LEFT_DOWN,
data: 0,
x: 0,
y: 0
});
sendCursorEvent({
event: cursorEvents.LEFT_UP,
data: 0,
x: 0,
y: 0
});
//Scroll wheel
sendCursorEvent({
event: cursorEvents.WHEEL,
data: 120, //amount of wheel movement
x: 0,
y: 0
});
const NodeCursor = require("node-cursor");
NodeCursor.getCursorPosition();
//Return: { x: 0, y: 0 }
NodeCursor.setCursorPosition({
x: 0,
y: 0
});
//Send mouse click at 0, 0
NodeCursor.sendCursorEvent({
event: NodeCursor.cursorEvents.LEFT_DOWN,
data: 0,
x: 0,
y: 0
});
NodeCursor.sendCursorEvent({
event: NodeCursor.cursorEvents.LEFT_UP,
data: 0,
x: 0,
y: 0
});
//Scroll wheel
NodeCursor.sendCursorEvent({
event: NodeCursor.cursorEvents.WHEEL,
data: 120, //amount of wheel movement
x: 0,
y: 0
});
import {cursorEvents} from "node-cursor";
cursorEvents.LEFT_DOWN //0x0002
cursorEvents.LEFT_UP //0x0004
cursorEvents.RIGHT_DOWN //0x0008
cursorEvents.RIGHT_UP //0x0010
cursorEvents.MIDDLE_DOWN //0x0020
cursorEvents.MIDDLE_UP //0x0040
cursorEvents.WHEEL //0x0800
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.