Mouse
Mouse module for dost. This module contains functions for mouse control.
Examples:
>>> from dost 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.
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". Defaults to "left". Possible values: "left", "l", "right", "r", "middle", "m". |
'left'
|
clicks |
int
|
Number of times to click the mouse button. Defaults to 1. |
1
|
absolute |
bool
|
Whether the co-ordinates are absolute or relative to the current position. Defaults to True. |
True
|
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. Defaults to 0.9. |
0.9
|
wait |
int
|
The time to wait for the image to appear. Defaults to 10. |
10
|
left_click |
bool
|
Whether to left click on the image. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Union[Tuple[int, int], List[Tuple[int, int]], None]
|
tuple || list of tuples : A tuple containing the X and Y co-ordinates of the image. |
Examples: