class MouseAction(object): def __init__(self): self.mouse = PyMouse() def single_click(self, valid_call): if not valid_call: return # TODO: Single click pass def double_click(self, valid_call): if not valid_call: return # TODO: Double click pass def move(self, xyz): if not xyz: return current_position = list(self.mouse.position()) current_position.append(0) current_position = Vector3D(current_position) target = current_position + xyz print current_position, target print 'move to ' + str([target.x, target.y]) self.mouse.move(target.x, target.y)
def render_GET(self, request): m = PyMouse() if request.args.get('start',0) != 0: self.originPosition = m.position() elif request.args.get('click',0) != 0: m.click(m.position()[0],m.position()[1],int(request.args.get('click',0)[0])) elif request.args.get('press',0) != 0: m.press(m.position()[0],m.position()[1],int(request.args.get('press',0)[0])) elif request.args.get('release',0) != 0: m.release(m.position()[0],m.position()[1],int(request.args.get('release',0)[0])) else: x = request.args.get('x',0)[0] y = request.args.get('y',0)[0] m.move(self.originPosition[0]+float(x), self.originPosition[1]+float(y))