当前位置: 首页>>代码示例>>Python>>正文


Python PyMouse.move方法代码示例

本文整理汇总了Python中pymouse.PyMouse.move方法的典型用法代码示例。如果您正苦于以下问题:Python PyMouse.move方法的具体用法?Python PyMouse.move怎么用?Python PyMouse.move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymouse.PyMouse的用法示例。


在下文中一共展示了PyMouse.move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mouse_simulate

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
def mouse_simulate():
    try:
        class event(PyMouseEvent):
            def move(self, x, y):
                pass

            def click(self, x, y, button, press):
                if press:
                    print("Mouse pressed at", x, y, "with button", button)
                else:
                    print("Mouse released at", x, y, "with button", button)
        e = event()
        e.start()

    except ImportError:
        print("Mouse events are not yet supported on your platform")

    m = PyMouse()

    t_corr = (1173,313)
    i_pos = t_corr
    m.move(i_pos[0] , i_pos[1])

    while(True):
        if is_run is False:
            time.sleep(1)
        else:
            time.sleep(0.2)
            m.click(i_pos[0], i_pos[1])

    try:
        e.stop()
    except:
        pass
开发者ID:lion117,项目名称:fuck_alipay_xiuxiu_D,代码行数:36,代码来源:auto_xiuxiu.py

示例2: vis

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
class Mouse:

	@property
	def vis(self):
		return self._vis

	def __init__(self,vis):
		self._vis = vis
		self.pm = PM()

	""" Takes a board coordinate (x,y) and uses self._vis to calculate the
	screen coordinates to click there. Then it waits 5.7 ms, and takes a 
	screenshot"""
	def left_click(self,x,y):
		#print "clicking at",x,y
		x0, y0 = self.vis.edge_coords
		x1, y1 = (x0 + 8 + x * 16, y0 + 8 + y * 16)
		self.pm.move(x1,y1)
		self.pm.click(x1,y1,1)
		#time.sleep(0.25)
	
	def right_click(self,x,y):
		x0, y0 = self.vis.edge_coords
		x1, y1 = (x0 + 8 + x * 16, y0 + 8 + y * 16)
		self.pm.click(x1,y1,2)
		#time.sleep(0.05)

	""" Uses self._vis to determine the position of the smiley reset button"""
	def reset_board(self):
		(resx, resy) = self.vis.get_reset()
		self.pm.move(resx,resy)
		self.pm.press(resx,resy,1)
		time.sleep(0.5)
		self.pm.release(resx,resy,1)
开发者ID:aWarmWalrus,项目名称:MSIntegratedSweeper,代码行数:36,代码来源:mouse.py

示例3: test_move

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
 def test_move(self):
     for size in screen_sizes:
         with Display(visible=VISIBLE, size=size):
             mouse = PyMouse()
             for p in positions:
                 mouse.move(*p)
                 eq_(expect_pos(p, size), mouse.position())
开发者ID:2008820,项目名称:PyUserInput,代码行数:9,代码来源:test_unix.py

示例4: move

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
def move ():
    deadzone_x = 200
    deadzone_y = 200
    key_delay = 0.4
    
    mouse = PyMouse()
    
    PORT = "/dev/ttyACM1"
    #~ PORT = "/dev/serial/by-id/usb-MBED_MBED_CMSIS-DAP_9900023431864e45001210060000003700000000cc4d28bd-if01"
    BAUD = 115200
    
    s = serial.Serial(PORT)
    s.baudrate = BAUD
    s.parity = serial.PARITY_NONE
    s.databits = serial.EIGHTBITS
    s.stopbits = serial.STOPBITS_ONE
    
    while True:
        data = s.readline().decode('UTF-8')
        data_list = data.rstrip().split(' ')
        try:
            x, y, z, a, b = data_list
            x_mapped = arduino_map(int(x), -1024, 1024, -960, 960)
            y_mapped = arduino_map(int(y), -1024, 1024, -540, 540)
            
            x_centre = 960
            y_centre = 540
        
            print(x_mapped, y_mapped)
            mouse.move(x_centre + x_mapped, y_centre + y_mapped)
        
        except:
            pass
        
    s.close()
开发者ID:ThinkPhysics,项目名称:NaffulusRift,代码行数:37,代码来源:lookcontroller-pyuserinput.py

示例5: netflix_play

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
def netflix_play():
    m = PyMouse()
    m.move(150, 640)
    time.sleep(0.25)
    m.click(150, 640)
    m.move(300, 0)
    return ""
开发者ID:mhielscher,项目名称:htpc-control,代码行数:9,代码来源:htpc.py

示例6: move_down

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
def move_down():
    m = PyMouse()
    xt=random.randint(1400, 1600)
    yt=random.randint(700, 800)

    m.position()
    m.move(xt, yt)
开发者ID:chengyake,项目名称:karch,代码行数:9,代码来源:jump.py

示例7: __init__

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
class Mouse:
    def __init__(self):
        import autopy
        from pymouse import PyMouse

        self.m1 = autopy.mouse
        self.loc = [self.m1.get_pos()[0],self.m1.get_pos()[1]]
        self.m = PyMouse()
        self.m.move(self.loc[0], self.loc[1])

    def move(self,direction):
        #Move mouse
        self.loc[0] += direction[0]
        self.loc[1] += direction[1]
        #FIXME: Support multiple displays
        #Check horizontal bounds
        self.loc[0] = min(self.loc[0],3600)#self.m.screen_size()[0])
        self.loc[0] = max(self.loc[0],0)
        #Check vertical bounds
        self.loc[1] = min(self.loc[1],self.m.screen_size()[1])
        self.loc[1] = max(self.loc[1],0)
        self.m.move(int(self.loc[0]), int(self.loc[1]))

    def click(self,button):
        self.m1.click(button)
开发者ID:trafficone,项目名称:ControllerKeyboard,代码行数:27,代码来源:controller.py

示例8: WinMouseControl

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
class WinMouseControl():
    
    mouseObject=''
    def __init__(self):
        self.mouseObject=PyMouse()
        print "mouse init success"
        pass
    
    def __del__(self):
        pass
    
    def mouseMove(self,x,y,button=None):
        self.mouseObject.move(x, y)
        return 0
    
    def mouseClick(self,x,y,button):
        self.mouseObject.click(x, y, button)   #button:1 left, button2: middle button3:right
        return 0
    
    def mousePress(self,x,y,button):
        self.mouseObject.press(x, y, button)   #button:1 left, button2: middle button3:right
        return 0
    
    def mouseRelease(self,x,y,button):
        self.mouseObject.release(x, y, button)   #button:1 left, button2: middle button3:right
        return 0
开发者ID:neltica,项目名称:Total-control,代码行数:28,代码来源:WinMouseControl.py

示例9: netflix_continue

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
def netflix_continue():
    m = PyMouse()
    x, y = m.screen_size()
    m.click(x/2, y/2-60)
    time.sleep(0.33)
    m.move(x/2, 0)
    return ""
开发者ID:mhielscher,项目名称:htpc-control,代码行数:9,代码来源:htpc.py

示例10: drag

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
def drag(source, dest, speed=1000):
    """
    Simulates a smooth mouse drag

    Args:
        source (int, int) : location (x,y) to start the drag, in screen 
            coordinates
        dest (int, int) : location (x,y) to end the drag, in screen 
            coordinates
        speed (int) : rate at which to execute the drag, in pixels/second
    """
    m = PyMouse()
    m.press(*source)

    time.sleep(0.1)

    # number of intermediate movements to make for our given speed
    npoints = int(sqrt((dest[0]-source[0])**2 + (dest[1]-source[1])**2 ) / (speed/1000))
    for i in range(npoints):
        x = int(source[0] + ((dest[0]-source[0])/npoints)*i)
        y = int(source[1] + ((dest[1]-source[1])/npoints)*i)
        m.move(x,y)
        time.sleep(0.001)

    m.release(*dest)
开发者ID:boylea,项目名称:qtbot,代码行数:27,代码来源:robouser.py

示例11: main

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
def main():
    mouse = PyMouse()

    # 	wm = cwiid.Wiimote("00:25:A0:CE:3B:6D")
    wm = cwiid.Wiimote()
    wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_IR

    X, x = calibrate(wm)
    trans = getTransMatrix(x, X)

    screen = mouse.screen_size()
    lastTime = time.time()
    o = None

    state = NEUTRAL

    print("battery: %f%%" % (float(wm.state["battery"]) / float(cwiid.BATTERY_MAX) * 100.0))

    window = pygame.display.set_mode((200, 150))

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit(0)

        pos = getWiiPointNonBlock(wm)

        if pos != None:
            ipt = numpy.matrix([[pos.x], [pos.y], [1]])
            optMat = trans.I * ipt
            o = Point(optMat[0] / optMat[2], optMat[1] / optMat[2])

            if o.x < 0:
                o.x = 0
            elif o.x >= screen[0]:
                o.x = screen[0] - 1

            if o.y < 0:
                o.y = 0
            elif o.y >= screen[1]:
                o.y = screen[1] - 1

            if state == NEUTRAL:
                state = FIRST_INPUT
                lastTime = time.time()
            elif state == FIRST_INPUT:
                if time.time() - FIRST_INPUT_TO_PRESSED > lastTime:
                    mouse.press(o.x, o.y)
                    state = PRESSED
            elif state == PRESSED:
                mouse.move(o.x, o.y)

        if state == FIRST_INPUT and pos == None and time.time() - FIRST_INPUT_TO_PRESSED < lastTime:
            mouse.click(o.x, o.y)
            time.sleep(0.2)
            state = NEUTRAL

        if state == PRESSED and pos == None and time.time() - 1 > lastTime:
            mouse.release(o.x, o.y)
            state = NEUTRAL
开发者ID:mrhubbs,项目名称:WiiTouch,代码行数:62,代码来源:WiiTouch.py

示例12: Robot

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
class Robot(object):

    def __init__(self):
        self.mouse = PyMouse()
        self.keyboard = PyKeyboard()
        self.przyciskPSP2klawiatura = {'up': 'w', 'right': 'd', 'down': 's', 'left': 'a', 'triangle': self.keyboard.enter_key,
                                       'circle': 'f', 'cross': 'g', 'square': 'h', 'l': self.keyboard.control_r_key, 'r': self.keyboard.shift_r_key, 'start': 'k', 'select': 'l'}

    def reaguj(self, x, y, przyciskPSP2Stan):
        self.reaguj_mysz(x, y)
        self.reaguj_klawiatura(przyciskPSP2Stan)

    def reaguj_mysz(self, x, y):
        max_predkosc_kursora = 0.00000000000000000000000000000000000000000000000000001
        x += int((x / float(128)) * max_predkosc_kursora +
                 self.mouse.position()[0])
        y += int((y / float(128)) * max_predkosc_kursora +
                 self.mouse.position()[1])
        x, y = min(self.mouse.screen_size()[0], x), min(
            self.mouse.screen_size()[1], y)
        x, y = max(0, x), max(0, y)
        self.mouse.move(x, y)

    def reaguj_klawiatura(self, przyciskPSP2Stan):
        for przycisk_psp, czyWcisniety in przyciskPSP2Stan.iteritems():
            przycisk_klawiaturowy = self.przyciskPSP2klawiatura[przycisk_psp]
            if czyWcisniety == '1':
                if przycisk_klawiaturowy == 'g':
                    self.mouse.click(*self.mouse.position())
                    break
                self.keyboard.press_key(przycisk_klawiaturowy)
            else:
                self.keyboard.release_key(przycisk_klawiaturowy)
开发者ID:ILoveMuffins,项目名称:psp-rmt-ctrl,代码行数:35,代码来源:Robot.py

示例13: __init__

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
class MenuOjoData:

    DEGREEE_PATTERN = r"(?P<degree_data>[+-]\d{2})"

    def __init__(self):
        self.driver = PantojoBluetoothReceiver()
        self.pipes = [PantojoRealDataPipe()]
        self.mouse = PyMouse()
        (self.x_max, self.y_max) = self.mouse.screen_size()
        self.degree = re.compile(self.DEGREEE_PATTERN, re.VERBOSE)

    def open(self):
        self.driver.open()

    def recv(self):
        data = self.driver.recv()
        for pipe in self.pipes:
            data = pipe.apply(data)
        matched = self.degree.match(data)
        if matched:
            valor = int(data)
        (x, y) = self.mouse.position()
        if (valor != 0):
            #asumo que se mueve de a 15
            mov = (self.x_max / 7) * (valor / 15) + x
            self.mouse.move(mov, y)
        else:
            self.mouse.move(self.x_max / 2, y)
        return data

    def close(self):
        self.driver.close()
开发者ID:menuojo,项目名称:dev_python,代码行数:34,代码来源:movecursorbluetooth.py

示例14: draw_arc

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
    def draw_arc(self, window):
        #self.drawing_area.window.draw_arc(self.context, False, self._x, self._y, 70, 70, 0, 360*64)
	window.set_keep_below(True)
	window.hide()
	m = PyMouse()
	m.move(self._x, self._y)
	m.click(self._x, self._y, 1)
开发者ID:carloscarvallo,项目名称:screen-sweeping-line,代码行数:9,代码来源:example-blackbackground-exp.py

示例15: ut_showMouseLoc

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import move [as 别名]
	def ut_showMouseLoc(self):
		points = [(120,120), (600,480), (500,1000), (800,200)]
		m = PyMouse() # make mouse object
		for point in points:
			print "Moving to: ", point
			m.move(point[0],point[1])
			print "The Mouse is at:", m.position()
		print "Test complete!"	
开发者ID:thewill2live,项目名称:Sample_Code_Python,代码行数:10,代码来源:SpartanSmartBoard.py


注:本文中的pymouse.PyMouse.move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。