Mouse Actions
Keyboard Actions are actions to emulate an keyboard entry.
Actions
mouse.click
Click at mouse current position or at a X, Y if a position is given.
If a screen position if given, you should always set the X and Y positions to avoid any problem.
Parameters:
x (optional) - X position on screen to click (default=None - current position).
y (optional) - Y position on screen to click (default=None - current position).
button (optional) - defines witch mouse button should de used for click 'left', 'middle' or 'right' (default='left').
clicks (optional) - Defines how many clicks will be given (default=1).
move_click_delay (optional) - time in seconds between mouse move and mouse click. Usefull when using remote connections or slow applications (default=0).
Returns:
x - X position of mouse.
y - Y position of mouse.
Exceptions:
This action returns no Exception
mouse.click_element
Acts the same as chrome.click_element
mouse.click_image
Find the given image on screen and click on it. Will click at the position with best fit to template image.
Parameters:
template_image - the template image to find on screen and click on it.
threshold (optional) - definies the minimum percentage of match with template image (default=0.9 - 90%).
screenshot_img (optional) - Can set a image to find the template inside, or if setted to None will take a new screenshot (default=None).
timeout (optional) - numbers of seconds to wait until the template is displayed on screen (default=5).
clicks (optional) - Defines how many clicks will be given (default=1).
move_click_delay (optional) - time in seconds between mouse move and mouse click. Usefull when using remote connections or slow applications (default=0).
Returns:
x - X corresponding to the center of template matched.
y - Y corresponding to the center of template matched.
Exceptions:
ImageNotFoundException - when the template_image
could not be found after the timeout expires.
mouse.double_click
Double click at mouse current position or at a X, Y if a position is given.
If a screen position if given, you should always set the X and Y positions to avoid any problem.
Parameters:
x (optional) - number of X position on screen to click (default=None - current position).
y (optional) - number of Y position on screen to click (default=None - current position).
button (optional) - defines witch mouse button should de used for double click 'left', 'middle' or 'right' (default='left').
interval (optional) - interval between each click, for slower computers, consider set a higher value than default (default=0 - instantaneous).
move_click_delay (optional) - time in seconds between mouse move and mouse click. Usefull when using remote connections or slow applications (default=0).
Returns:
x - X position of mouse.
y - Y position of mouse.
Exceptions:
This action returns no Exception
mouse.drag_to
Drag mouse from the current position to the given X and Y end position.
Parameters:
x - number of X position go on the drag ends.
y - number of Y position go on the drag ends.
speed (optional) - number representing the seconds taken to move from the current position to the end position.
button (optional) - defines witch mouse button should de used for drag 'left', 'middle' or 'right' (default='left').
Returns:
x - X position of mouse.
y - Y position of mouse.
Exceptions:
This action returns no Exception
mouse.get_position
Return mouse current X, Y position.
Parameters:
None
Returns:
x - X position of mouse.
y - Y position of mouse.
Exceptions:
This action returns no Exception
mouse.mouse_down
Simulate a button press (click) without release the button.
Parameters:
button (optional) - defines witch mouse button should de used for mouse down 'left', 'middle' or 'right' (default='left').
Returns:
This action gives no return
Exceptions:
This action returns no Exception
mouse.mouse_up
Simulate a button release after a mouse.mouse_down action.
Parameters:
button (optional) - defines witch mouse button should de used for mouse down 'left', 'middle' or 'right' (default='left').
Returns:
This action gives no return
Exceptions:
This action returns no Exception
mouse.move
Move mouse position X, Y pixels relative to the current position.
Ex: if mouse is at 100, 100 and mouse.move(30, 50)
if called, will move the mouse cursor to 130, 150 X,Y position.
This action depends on mouse current position. If you want to move to an absolute position, use mouse.move_to action.
Parameters:
x - number with how many pixels to move from the current position. X could be a positive (move left) or negative (move right) number.
y - number with how many pixels to move from the current position. Y could be a positive (move down) or negative (move up) number.
speed (optional) - number of seconds for the mouse move from current position the X, Y new position.
Returns:
x - X final position of mouse.
y - Y final position of mouse.
Exceptions:
This action returns no Exception
mouse.move_to
Move mouse to X, Y position on screen.
Ex: if mouse is at 100, 100 and mouse.move_(30, 50)
if called, will move the mouse cursor to 30, 50 X,Y position.
This action is independant of the mouse current position. If you want to move relative to current position, use mouse.move action.
Parameters:
x (optional) - number with how many pixels to move from the current position. X could be a positive (move left) or negative (move right) number.
y (optional) - number with how many pixels to move from the current position. Y could be a positive (move down) or negative (move up) number.
speed (optional) - number of seconds for the mouse move from current position the X, Y new position.
Returns:
x - X final position of mouse.
y - Y final position of mouse.
Exceptions:
This action returns no Exception
mouse.multi_click
Perform a multiple click action at mouse current position or at a X, Y if a position is given.
If a screen position if given, you should always set the X and Y positions to avoid any problem.
Parameters:
x (optional) - number of X position on screen to click (default=None - current position).
y (optional) - number of Y position on screen to click (default=None - current position).
clicks (optionl) - number of clicks to be performed at position (default=1)
button (optional) - defines witch mouse button should de used for multiple clicks 'left', 'middle' or 'right' (default='left').
interval (optional) - interval between each click, for slower computers, consider set a higher value than default (default=0 - instantaneous).
move_click_delay (optional) - time in seconds between mouse move and mouse click. Usefull when using remote connections or slow applications (default=0).
Returns:
x - X position of mouse.
y - Y position of mouse.
Exceptions:
This action returns no Exception
mouse.scroll
Perform a scroll up or scroll down using the mouse scroll wheel.
Parameters:
size - number of pixels to scroll. Negative number performs a scroll down and positive number perform a scroll up.
Returns:
This action gives no return
Exceptions:
This action returns no Exception