Esempio n. 1
0
    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.
            """)
Esempio n. 2
0
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)
Esempio n. 3
0
 def test_position(self):
     self.assertEqual(mouse.get_position(), mouse.os_mouse.get_position())
Esempio n. 4
0
 def at(cls):
     """ Gets ``Location`` of cursor (as class method) """
     return Location(*mouse.get_position())
Esempio n. 5
0
 def getPos(self):
     """ Gets ``Location`` of cursor """
     return Location(*mouse.get_position())
Esempio n. 6
0
 def test_position(self):
     self.assertEqual(mouse.get_position(), mouse._os_mouse.get_position())
Esempio n. 7
0
 def getPos(self):
     """ Gets ``Location`` of cursor """
     from .Geometry import Location
     return Location(*mouse.get_position())