Skip to content

Commit

Permalink
mouse operation use relative coordinate
Browse files Browse the repository at this point in the history
Signed-off-by: xcgspring <[email protected]>
  • Loading branch information
xcgspring committed Dec 30, 2014
1 parent b4947f5 commit b3f1623
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions AXUI/driver/windows/win32/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,38 +265,47 @@ def __repr__(self):

return docstring

def LeftClick(self, coords = None):
def LeftClick(self, relative_coords = None):
'''LeftClick: left click the UI element, or taget coords
Arguments:
coords: coordinate indicate where mouse click, default use UI element click point
Returns:
'''
if coords is None:
if relative_coords is None:
coords = self.UIElement.GetClickablePoint()
else:
coords[0] = relative_coords[0]+self.UIElement.coordinate[0]
coords[1] = relative_coords[1]+self.UIElement.coordinate[1]

self.UIElement.SetFocus()
SendMouseInput(coords)

def LeftDoubleClick(self, coords = None):
def LeftDoubleClick(self, relative_coords = None):
'''LeftDoubleClick: left double click the UI element, or taget coords
Arguments:
coords: coordinate indicate where mouse click, default use UI element click point
Returns:
'''
if coords is None:
if relative_coords is None:
coords = self.UIElement.GetClickablePoint()
else:
coords[0] = relative_coords[0]+self.UIElement.coordinate[0]
coords[1] = relative_coords[1]+self.UIElement.coordinate[1]

self.UIElement.SetFocus()
SendMouseInput(coords, double=True)

def RightClick(self, coords = None):
def RightClick(self, relative_coords = None):
'''RightClick: right click the UI element, or taget coords
Arguments:
coords: coordinate indicate where mouse click, default use UI element click point
Returns:
'''
if coords is None:
if relative_coords is None:
coords = self.UIElement.GetClickablePoint()
else:
coords[0] = relative_coords[0]+self.UIElement.coordinate[0]
coords[1] = relative_coords[1]+self.UIElement.coordinate[1]

self.UIElement.SetFocus()
SendMouseInput(coords, button="right")
Expand Down

0 comments on commit b3f1623

Please sign in to comment.