Mouse
Mouse module for autopylot. This module contains functions for mouse control.
Examples:
>>> from autopylot import mouse
>>> mouse.click(x=100, y=100)
>>> mouse.search(image_path='tests\demo.png')
(23, 17)
The module contains the following functions:
click(x, y, button, clicks, absolute)
: Click at the given coordinates.search(image_path, conf, wait, left_click)
: Search for an image on the screen and return the coordinates of the top-left corner of the image.move(x, y, absolute)
: Move the mouse to the given coordinates.drag(x, y, button, absolute)
: Drag the mouse to the given coordinates.scroll(x, y, distance, absolute)
: Scroll the mouse wheel.
click(x, y, button='left', clicks=1, absolute=True)
Clicks the mouse at the given co-ordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
X co-ordinate. |
required |
y |
int
|
Y co-ordinate. |
required |
button |
str
|
The button to click. Can be "left", "right" or "middle". Possible values: "left", "l", "right", "r", "middle", "m". |
'left'
|
clicks |
int
|
Number of times to click the mouse button. |
1
|
absolute |
bool
|
Whether the co-ordinates are absolute or relative to the current position. |
True
|
Returns:
Type | Description |
---|---|
None
|
None |
Examples:
drag(x_start, y_start, x_end, y_end, absolute=True)
Drags the mouse from one point to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_start |
int
|
x-coordinate of the starting point. |
required |
y_start |
int
|
y-coordinate of the starting point. |
required |
x_end |
int
|
x-coordinate of the ending point. |
required |
y_end |
int
|
y-coordinate of the ending point. |
required |
absolute |
bool
|
Whether the co-ordinates are absolute or relative to the current position. |
True
|
Returns:
Type | Description |
---|---|
None
|
None |
Examples:
move(x, y, absolute=True)
Moves the cursor to the given X Y Co-ordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
x-coordinate on screen. |
required |
y |
int
|
y-coordinate on screen. |
required |
absolute |
bool
|
Whether the co-ordinates are absolute or relative to the current position. |
True
|
Returns:
Type | Description |
---|---|
None
|
None |
Examples:
scroll(x, y, dist, absolute=True)
Scrolls the mouse.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
x-coordinate on screen. |
required |
y |
int
|
y-coordinate on screen. |
required |
absolute |
bool
|
Whether the co-ordinates are absolute or relative to the current position. |
True
|
Returns:
Type | Description |
---|---|
None
|
None |
Examples:
search(image_path, conf=0.9, wait=10, left_click=False)
Searches for the given image and returns the co-ordinates of the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_path |
str || WindowsPath || list
|
The path to the image. |
required |
conf |
int
|
The confidence level. |
0.9
|
wait |
int
|
The time to wait for the image to appear. |
10
|
left_click |
bool
|
Whether to left click on the image. |
False
|
Returns:
Name | Type | Description |
---|---|---|
Positions |
tuple || list
|
A tuple containing the X and Y co-ordinates of the image. |
Examples: