mouse-controller v1.0.0
mouse-controller
Node.js C++ Addon for emulating mouse behavior
Table of Contents
Supported Plattforms
Currently supported plattforms are:
- MacOS
Installation
$ npm install --save mouse-controllerPrecompiled binaries for popular 64-bit platforms are provided. When installing mouse-controller, node-pre-gyp will check if a compatible binary exists and fallback to a compile step if it doesn't. In that case you'll need a valid node-gyp installation.
If you don't want to use the prebuilt binary for the platform you are installing on, specify the --build-from-source flag when you install. One of:
npm install --build-from-source
npm install mouse-controller --build-from-sourceUsage
Syntax
new MouseController()Example
const MouseController = require('mouse-controller');
const mc = new MouseController();
console.log(mc.getPosition());
//=> { x: 143.9375, y: 129.0625 }
// Move the mouse to the coordinates (500, 500).
mc.move(500, 500);
// Right click at the current mouse position.
mc.click(mc.BUTTON.RIGHT, mc.getPosition());Constants
BUTTON
Constant for specifying the mouse button type.
| Constant | Value | Button |
|---|---|---|
LEFT | 0 | Left mouse button |
RIGHT | 1 | Right mouse button |
Methods
move(x, y)
x:
- Type:
Number - x-coordinate for the new mouse position.
- Type:
y:
- Type:
Number - y-coordinate for the new mouse position.
- Type:
Moves the mouse to the point (x, y).
click(BUTTON, point)
BUTTON:
point:
- Type:
Object - Which mouse button to click.
- Type:
Clicks with the BUTTON at the point provided. To click in the corrent position of the mouse, use the method getPosition().
doubleClick(BUTTON, point)
BUTTON:
point:
- Type:
Object - Which mouse button to click.
- Type:
Double clicks with the BUTTON at the point provided. To click in the corrent position of the mouse, use the method getPosition().
getPosition()
- (return value):
- Type:
Object - Returns the current mouse position.
- Type:
Gets the current mouse position on the form { x: 143.9375, y: 129.0625 }.
startDrag(point)
- point:
- Type:
Object - Object with
xandycoordinates of the vanted mouse position to start the mouse drag from.
- Type:
Start to drag by pressing down on the left mouse button at the point (x, y). To do consecutive movement while dragging, use the drag(point) method.
drag(point)
- point:
- Type:
Object - Object with
xandycoordinates of the vanted mouse position to end the mouse drag on.
- Type:
To move the mouse that is activly dragging, the point (x, y).
endDrag(point)
- point:
- Type:
Object - Object with
xandycoordinates of the vanted mouse position to end the mouse drag on.
- Type:
End a mouse drag by releasing the left mouse button at the point (x, y).
License
mouse-controller is licensed under the MIT License.
Copyright © André Storhaug
6 years ago