Skip to content

oxylabs/OxyMouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐭 Oxy® Mouse

Generate mouse movements with Python & different algorithms

OxyMouse is a Python library for generating mouse movements.

It is designed to work with any browser control library that supports 2D moving of the mouse cursor.

Installation

pip install oxymouse

Usage

Specify algorithm an algorithm.

Supported algorithms:

bezier, gaussian, perlin

from oxymouse import OxyMouse

mouse = OxyMouse(algorithm="bezier")
movements = mouse.generate_random_coordinates(viewport_width=1920, viewport_height=1080)

generate_random_coordinates

This method will generate random coordinates based on your viewport width and viewport height.

generate_coordinates

This method will generate random coordinates from a given 2D point to another 2D point.

You can use this to generate movements to a button.

For example:

  • get button coordinates
  • get current mouse coordinates
  • generate movements from current mouse coordinates to button coordinates
from oxymouse import OxyMouse

mouse = OxyMouse(algorithm="bezier")
movements = mouse.generate_coordinates(from_x=400, from_y=500, to_x=1000, to_y=1200)

generate_scroll_coordinates

This method will generate random coordinates for scrolling.

from oxymouse import OxyMouse

mouse = OxyMouse(algorithm="bezier")
movements = mouse.generate_scroll_coordinates()

Supported Algorithms

Bezier

The Bezier algorithm generates mouse movements using the Bezier curve. Perfect for moving to click a button

bezier.png

Gaussian

The Gaussian algorithm generates mouse movements using the Gaussian distribution. Perfect for simulating human-like mouse movements

gaussian.png

Perlin

The Perlin algorithm generates mouse movements using the Perlin noise. Perfect for simulating human-like mouse movements

perlin.png

Testing

You can easily test generated mouse movements visually with specific algorithm.

Use the CLI to test the generated mouse movements.

For example, to test the generated mouse movements with the Bezier algorithm and generate_coordinates function.

python3 visualize.py bezier gc

You will see the generated mouse movements in a window. Similar in the examples above.

Other function names:

function_names_to_function_map = {
    "gc": "generate_coordinates",
    "grc": "generate_random_coordinates",
    "gsc": "generate_scroll_coordinates",
}

Contributing

Contributions are welcome! For feature requests and bug reports please submit an issue!