Skip to content

Commit

Permalink
Add mouse.drag
Browse files Browse the repository at this point in the history
  • Loading branch information
boppreh committed Jul 11, 2017
1 parent 4126dde commit 85a4162
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions keyboard/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ def move(x, y, absolute=True, duration=0):
else:
_os_mouse.move_to(x, y)

def drag(start_x, start_y, end_x, end_y, absolute=True, duration=0):
"""
Holds the left mouse button, moving from start to end position, then
releases. `absolute` and `duration` are parameters regarding the mouse
movement.
"""
if is_pressed():
release()
move(start_x, start_y, absolute, 0)
press()
move(end_x, end_y, absolute, duration)
release()

def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP, DOWN, DOUBLE)):
""" Invokes `callback` with `args` when the specified event happens. """
if not isinstance(buttons, (tuple, list)):
Expand Down

0 comments on commit 85a4162

Please sign in to comment.