Mouse API
- class autokey.scripting.Mouse(mediator)[source]
Provides access to send mouse clicks
- enum Button(value)
- Member Type:
int
Valid values are as follows:
- LEFT = <Button.LEFT: 1>
- MIDDLE = <Button.MIDDLE: 2>
- RIGHT = <Button.RIGHT: 3>
- SCROLL_UP = <Button.SCROLL_UP: 4>
- SCROLL_DOWN = <Button.SCROLL_DOWN: 5>
- SCROLL_LEFT = <Button.SCROLL_LEFT: 6>
- SCROLL_RIGHT = <Button.SCROLL_RIGHT: 7>
- BACKWARD = <Button.BACKWARD: 8>
- FORWARD = <Button.FORWARD: 9>
- BUTTON10 = <Button.BUTTON10: 10>
- click_absolute(x, y, button)[source]
Send a mouse click relative to the screen (absolute)
Usage:
mouse.click_absolute(x, y, button)- Parameters:
x – x-coordinate in pixels, relative to upper left corner of window
y – y-coordinate in pixels, relative to upper left corner of window
button – mouse button to simulate (left=1, middle=2, right=3)
- click_relative(x, y, button)[source]
Send a mouse click relative to the active window
Usage:
mouse.click_relative(x, y, button)- Parameters:
x – x-coordinate in pixels, relative to upper left corner of window
y – y-coordinate in pixels, relative to upper left corner of window
button – mouse button to simulate (left=1, middle=2, right=3)
- click_relative_self(x, y, button)[source]
Send a mouse click relative to the current mouse position
Usage:
mouse.click_relative_self(x, y, button)- Parameters:
x – x-offset in pixels, relative to current mouse position
y – y-offset in pixels, relative to current mouse position
button – mouse button to simulate (left=1, middle=2, right=3)
- get_location()[source]
Returns the current location of the mouse. Incorporates a tiny delay in order to make sure AutoKey executes any queued commands before checking the location. C{mouse.move_cursor(0,0) x,y = mouse.get_location()}
Usage:
mouse.get_location()- Returns:
x,y location of the mouse
- Return type:
tuple(int,int)
- get_relative_location()[source]
Returns the relative location of the mouse in the window that has input focus Incorporates a tiny delay in order to make sure AutoKey executes any queued commands
Usage:
mouse.get_relative_location()- Returns:
x,y location of the mouse relative to the top left hand corner of the window that has input focus
- Return type:
tuple(int, int)
- move_cursor(x, y)[source]
Move mouse cursor to xy location on screen without warping back to the start location
Usage:
mouse.move_cursor(x,y)- Parameters:
x – x-coordinate in pixels, relative to upper left corner of screen
y – y-coordinate in pixels, relative to upper left corner of screen
- move_relative(x, y)[source]
Move cursor relative to xy location based on the top left hand corner of the window that has input focus
Usage:
mouse.move_relative(x,y)- Parameters:
x – x-coordinate in pixels, relative to upper left corner of window
y – y-coordinate in pixels, relative to upper left corner of window
- move_relative_self(x, y)[source]
Move cursor relative to the location of the mouse cursor
Usage:
mouse.move_relative_self(x,y)- Parameters:
x – x-coordinate in pixels, relative to current position of mouse cursor
y – y-coordinate in pixels, relative to current position of mouse cursor
- press_button(button)[source]
Send mouse button down signal at current location
Usage:
mouse.press_button(button)- Parameters:
button – the mouse button to press down
- release_button(button)[source]
Send mouse button up signal at current location
Usage:
mouse.release_button(button)- Parameters:
button – the mouse button to press down
- scroll_down(number)[source]
Fires the mouse button 5 signal the specified number of times.
Note that the behavior of these methods are effected (and untested) by programs like imwheel.
Usage:
mouse.scroll_down()- Parameters:
number – The number of times the scroll up signal will be fired.
- scroll_up(number)[source]
Fires the mouse button 4 signal the specified number of times.
Note that the behavior of these methods are effected (and untested) by programs like imwheel.
Usage:
mouse.scroll_up()- Parameters:
number – The number of times the scroll up signal will be fired.
- select_area(startx, starty, endx, endy, button, scrollNumber=0, down=True, warp=True)[source]
“Drag and Select” for an area with the top left corner at (startx, starty) and the bottom right corner at (endx, endy) and uses
buttonfor the mouse button held downUsage:
mouse.select_area(startx, starty, endx, endy, button)- Parameters:
startx – X coordinate of where to start the drag and select
starty – Y coordinate of where to start the drag and select
endx – X coordinate of where to end the drag and select
endy – Y coordinate of where to end the drag and select
button – What mouse button to press at the start coordinates and release at the end coordinates
scrollNumber – Number of times to scroll, defaults to 0
down – Boolean to choose which direction to scroll, True for down, False for up., defaults to scrolling down.
warp – If True method will return cursor to the position it was at at the start of execution