Giter Site home page Giter Site logo

kritarthh / cnaturalmousemotion Goto Github PK

View Code? Open in Web Editor NEW

This project forked from barrybingo/cnaturalmousemotion

0.0 0.0 0.0 39 KB

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

License: MIT License

CMake 2.87% C++ 97.07% C 0.07%

cnaturalmousemotion's Introduction

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

cnaturalmousemotion's People

Contributors

barrybingo avatar hinyb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.