def relativeMotion(x, y, mouseDelay=None): logger.log("Mouse relative motion of (%s,%s)" % (x, y)) registry.generateMouseEvent(x, y, 'rel') if mouseDelay: doDelay(mouseDelay) else: doDelay()
def absoluteMotionWithTrajectory(source_x, source_y, dest_x, dest_y, mouseDelay=None, check=True): """ Synthetize mouse absolute motion with trajectory. The 'trajectory' means that the whole motion is divided into several atomic movements which are synthetized separately. """ if check: checkCoordinates(source_x, source_y) checkCoordinates(dest_x, dest_y) logger.log("Mouse absolute motion with trajectory to (%s,%s)" % (dest_x, dest_y)) dx = float(dest_x - source_x) dy = float(dest_y - source_y) max_len = max(abs(dx), abs(dy)) if max_len == 0: # actually, no motion requested return dx /= max_len dy /= max_len act_x = float(source_x) act_y = float(source_y) for _ in range(0, int(max_len)): act_x += dx act_y += dy if mouseDelay: doDelay(mouseDelay) registry.generateMouseEvent(int(act_x), int(act_y), name='abs') if mouseDelay: doDelay(mouseDelay) else: doDelay()
def mouse_event(x, y, button, eventType): """ > Description Generates a mouse press or release event on a specific pixel on the screen > Parameters x (int): the x coordinate where the event will be generated y (int): the y coordinate where the event will be generated button (str): A string indicating which mouse button to press/release. One of 'left', 'right' or 'middle' eventType (str): A string indicating the event type. One of 'press' or 'release' > Returns None > Example # this example could demonstrate a drag and drop of a file # press the left mouse button at 100, 100 Macro.mouse_event(100, 100, 'left', 'press') # move the cursor to 400, 400 Macro.move_cursor_to(400, 400) # then, release the mouse Macro.mouse_event(400, 400, 'left', 'press') """ buttonToNo = {'left': 1, 'right': 2, 'middle': 3} controller.generateMouseEvent( x, y, 'b' + str(buttonToNo[button]) + ('p' if eventType == 'press' else 'r'))
def mouse_event(x, y, button, eventType): """ > Description Generates a mouse press or release event on a specific pixel on the screen > Parameters x (int): the x coordinate where the event will be generated y (int): the y coordinate where the event will be generated button (str): A string indicating which mouse button to press/release. One of 'left', 'right' or 'middle' eventType (str): A string indicating the event type. One of 'press' or 'release' > Returns None > Example # this example could demonstrate a drag and drop of a file # press the left mouse button at 100, 100 Macro.mouse_event(100, 100, 'left', 'press') # move the cursor to 400, 400 Macro.move_cursor_to(400, 400) # then, release the mouse Macro.mouse_event(400, 400, 'left', 'press') """ buttonToNo = {'left':1, 'right':2, 'middle':3 } controller.generateMouseEvent(x, y, 'b' + str(buttonToNo[button]) + ('p' if eventType == 'press' else 'r'))
def release(x, y, button=1, check=True): """ Synthesize a mouse button release at (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse button %s release at (%s,%s)" % (button, x, y)) registry.generateMouseEvent(x, y, name='b%sr' % button) doDelay()
def click(x, y, button=1, check=True): """ Synthesize a mouse button click at (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse button %s click at (%s,%s)" % (button, x, y)) registry.generateMouseEvent(x, y, name='b%sc' % button) doDelay(config.actionDelay)
def doubleClick(x, y, button=1, check=True): """ Synthesize a mouse button double-click at (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse button %s doubleclick at (%s,%s)" % (button, x, y)) registry.generateMouseEvent(x, y, name='b%sd' % button) doDelay()
def doubleClick(x, y, button=1, check=True): """ Synthesize a mouse button double-click at (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse button %s doubleclick at (%s,%s)" % (button, x, y)) registry.generateMouseEvent(x, y, 'b%sd' % button) doDelay()
def click(x, y, button=1, check=True): """ Synthesize a mouse button click at (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse button %s click at (%s,%s)" % (button, x, y)) registry.generateMouseEvent(x, y, 'b%sc' % button) doDelay(config.actionDelay)
def release(x, y, button=1, check=True): """ Synthesize a mouse button release at (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse button %s release at (%s,%s)" % (button, x, y)) registry.generateMouseEvent(x, y, 'b%sr' % button) doDelay()
def press(x, y, button=1, check=True): """ Synthesize a mouse button press at (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse button %s press at (%s,%s)" % (button, x, y)) registry.generateMouseEvent(x, y, name='b%sp' % button) doDelay()
def relativeMotion(x, y, mouseDelay=None): """ Synthetize a relative motion from actual position. Note: Does not check if the end coordinates are positive. """ logger.log("Mouse relative motion of (%s,%s)" % (x, y)) registry.generateMouseEvent(x, y, name='rel') if mouseDelay: doDelay(mouseDelay) else: doDelay()
def absoluteMotion(x, y, mouseDelay=None, check=True): """ Synthesize mouse absolute motion to (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse absolute motion to (%s,%s)" % (x, y)) registry.generateMouseEvent(x, y, 'abs') if mouseDelay: doDelay(mouseDelay) else: doDelay()
def absoluteMotion(x, y, mouseDelay=None, check=True): """ Synthesize mouse absolute motion to (x,y) """ if check: checkCoordinates(x, y) logger.log("Mouse absolute motion to (%s,%s)" % (x, y)) registry.generateMouseEvent(x, y, name='abs') if mouseDelay: doDelay(mouseDelay) else: doDelay()
def move_cursor_to(x, y): """ > Description Moves the cursor to the x, y coordinates > Parameters x (int): the x coordinate to move the cursor to y (int): the y coordinate to move the cursor to > Returns None > Example # move the cursor to 100, 100 Macro.move_cursor_to(100, 100) """ controller.generateMouseEvent(x, y, MOUSE_ABS)
def right_click_to(x, y): """ > Description Right clicks the mouse at x, y > Parameters x (int): the x coordinate to right click to y (int): the y coordinate to right click to > Returns None > Example # right click to 100, 100 Macro.right_click_to(100, 100) """ if (x >= 0 and y >= 0): controller.generateMouseEvent(x, y, 'b3c')
def middle_click_to(x, y): """ > Description Middle clicks the mouse at x, y > Parameters x (int): the x coordinate to middle click to y (int): the y coordinate to middle click to > Returns None > Example # middle click to 100, 100 Macro.middle_click_to(100, 100) """ if (x >= 0 and y >= 0): controller.generateMouseEvent(x, y, 'b2c')
def right_click_to(x, y): """ > Description Right clicks the mouse at x, y > Parameters x (int): the x coordinate to right click to y (int): the y coordinate to right click to > Returns None > Example # right click to 100, 100 Macro.right_click_to(100, 100) """ if(x >= 0 and y >= 0): controller.generateMouseEvent(x, y, 'b3c')
def middle_click_to(x, y): """ > Description Middle clicks the mouse at x, y > Parameters x (int): the x coordinate to middle click to y (int): the y coordinate to middle click to > Returns None > Example # middle click to 100, 100 Macro.middle_click_to(100, 100) """ if(x >= 0 and y >= 0): controller.generateMouseEvent(x, y, 'b2c')
def double_click(self, button=1): self.widow_hide() x, y = self.get_center() registry.generateMouseEvent(x, y, 'b%sd' % button)
def move_cursor_to(self, x, y): """Moves the cursor to the x, y coordinates""" controller.generateMouseEvent(x, y, MOUSE_ABS)
def middle_click_to(self, x, y): """Middle clicks the cursor to the x, y coordinates""" if x >= 0 and y >= 0: controller.generateMouseEvent(x, y, "b2c")
def right_click_to(self, x, y): """Right clicks the cursor to the x, y coordinates""" if x >= 0 and y >= 0: controller.generateMouseEvent(x, y, "b3c")
def double_click(self, button = 1): self.widow_hide() x,y = self.get_center() registry.generateMouseEvent(x, y, 'b%sd' % button)
def point(self): x,y = self.get_center() registry.generateMouseEvent(x, y, 'abs')
def point(self): x, y = self.get_center() registry.generateMouseEvent(x, y, 'abs')
def point(x, y, check=True): if check: checkCoordinates(x, y) logger.log("Pointing mouse cursor at (%s,%s)" % (x, y)) registry.generateMouseEvent(x, y, 'abs') doDelay(config.actionDelay)