Node.js C++ Addon for emulating mouse behavior
Currently supported plattforms are:
- MacOS
$ npm install --save mouse-controller
Precompiled 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-source
new MouseController()
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());
Constant for specifying the mouse button type.
Constant | Value | Button |
---|---|---|
LEFT |
0 |
Left mouse button |
RIGHT |
1 |
Right mouse button |
-
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
).
-
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().
-
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().
- (return value):
- Type:
Object
- Returns the current mouse position.
- Type:
Gets the current mouse position on the form { x: 143.9375, y: 129.0625 }
.
- point:
- Type:
Object
- Object with
x
andy
coordinates 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.
- point:
- Type:
Object
- Object with
x
andy
coordinates of the vanted mouse position to end the mouse drag on.
- Type:
To move the mouse that is activly dragging, the point (x
, y
).
- point:
- Type:
Object
- Object with
x
andy
coordinates 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
).
mouse-controller is licensed under the MIT License.
Copyright © André Storhaug