node-natural-mouse
v1.0.1
Published
Node.js module for natural mouse motion
Downloads
4
Readme
Giving credit for initial implementation: https://github.com/JoonasVali/NaturalMouseMotion
And also for the C++11 translation: https://github.com/barrybingo/CNaturalMouseMotion
There are missing features in the C++11 implementation, and I will be adding them as I need them. I will also be adding a few more features that I think are useful.
Installation Instructions
npm install natural-mouse-motion
yarn add natural-mouse-motion
Usage
const { move } = require('natural-mouse-motion');
move("fastGamer", 250, 250);
Below is the original README.md from the C++ implementation:
CNaturalMouseMotion
Move the mouse like a human via code.
This is a C++11 header only port of Joonas Vali's Java NatualMouseMotion at https://github.com/JoonasVali/NaturalMouseMotion
Distinctions:
- Less factories
- No getters/setters
- Classes that wrap single functions have been replaced by std::function, or structs with operator() that can be contained in std::function
- No ScreenAdjustedNature - TODO possibly add later; for multiple screens could add a screen parameter to nature or move(x,y,screen)
- Move is a single function that takes a nature and coordinates, so everything not coordinates resides in MotionNature
Features:
- Deviation: Deviation leads the mouse away from direct trajectory, creating and arc instead of straight line
- Noise: Noise creates errors in the movement, this can simulate hand shakiness, someone using a non accurate mouse or bad surface under the mouse.
- Speed and flow: Speed and flow are defining the progressing of the mouse at given time, for example it's possible that movement starts slow and then gains speed, or is just variating.
- Overshoots: Overshoots happen if user is not 100% accurate with the mouse and hits an area next to the target instead, requiring to adjust the cursor to reach the actual target.
- Coordinate translation: Coordinate translation allows to specify offset and dimensions to restrict a movement in a different area than the screen or in a virtual screen inside the real screen.
Usage:
Moving the mouse requires destination cooridnates and a nature of movement. Destination cooridnates are self exmplanatory though require a little thinking about with multiple screens.
#include "NaturalMouseMotion.h"
int main(int argc, char** argv)
{
auto nature = NaturalMouseMotion::DefaultNature::NewFastGamerNature();
NaturalMouseMotion::Move(&nature, 250, 250);
return 0;
}
Building Tests and Example:
Linux:
mkdir build
cd build
cmake ..
make
# Run tests
./Test/NaturalMouseMotion_test
# Run the example CLI
./Example/NaturalMouseMotion -i -f -x 500 -y 500
Windows:
Easy way is to use VSCode with a cmake plugin (CMake Tools) and a gtest plugin (GoogleTest Adapter)
Precooked Natures
- GrannyMotionNature is a slow and clumsy mouse movement with a lot of noise.
- FastGamerMotionNature is a fast and persistent movement with low noise, simulating behavior of someone who knows where the click should land, like a professional gamer.
- AverageComputerUserMotionNature is a medium speed movement with average settings, slower than fast gamer, but much faster than granny motion.
- RobotMotionNature is featureless constant speed robotic movement with no mistakes.
TODO
- ScreenAdjustedNature or at least support multiple screens
- Remove throws