def moveSpeed(self, location, seconds=0.3): """ Moves cursor to specified ``Location`` over ``seconds``. If ``seconds`` is 0, moves the cursor immediately. Used for smooth somewhat-human-like motion. """ original_location = mouse.get_position() mouse.move(location.x, location.y, duration=seconds) if mouse.get_position( ) == original_location and original_location != location.getTuple(): raise IOError(""" Unable to move mouse cursor. This may happen if you're trying to automate a program running as Administrator with a script running as a non-elevated user. """)
def KeyPressed(): nextmove = [] while True: if mouse.is_pressed('left'): sqr = get_square(mouse.get_position()) if sqr not in nextmove and sqr != None: nextmove.append(sqr) if len(nextmove) == 2: return nextmove if mouse.is_pressed('right'): sqr = get_square(mouse.get_position()) if sqr in nextmove and sqr != None: nextmove.remove(sqr)
def test_position(self): self.assertEqual(mouse.get_position(), mouse.os_mouse.get_position())
def at(cls): """ Gets ``Location`` of cursor (as class method) """ return Location(*mouse.get_position())
def getPos(self): """ Gets ``Location`` of cursor """ return Location(*mouse.get_position())
def test_position(self): self.assertEqual(mouse.get_position(), mouse._os_mouse.get_position())
def getPos(self): """ Gets ``Location`` of cursor """ from .Geometry import Location return Location(*mouse.get_position())