https://github.com/oxylabs/oxymouse
Mouse Movement Algorithms
https://github.com/oxylabs/oxymouse
Last synced: 8 months ago
JSON representation
Mouse Movement Algorithms
- Host: GitHub
- URL: https://github.com/oxylabs/oxymouse
- Owner: oxylabs
- License: mit
- Created: 2024-09-16T12:41:36.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-09T08:29:43.000Z (9 months ago)
- Last Synced: 2025-04-09T09:34:36.221Z (9 months ago)
- Language: Python
- Size: 436 KB
- Stars: 212
- Watchers: 3
- Forks: 25
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
🐭 Oxy® Mouse
Generate mouse movements with Python & different algorithms
[](https://discord.gg/Pds3gBmKMH)
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
```bash
pip install oxymouse
```
## Usage
Specify `algorithm` an algorithm.
Supported algorithms:
`bezier`, `gaussian`, `perlin`, 'oxy'
```python
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
```python
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.
```python
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

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

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

### OxyMouse
Custom algorithm that generates mouse movements using a custom algorithm.

### 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.
```bash
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!