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


Python PyMouse.release方法代码示例

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


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

示例1: main

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [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

示例2: vis

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [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: drag

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [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

示例4: WinMouseControl

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [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

示例5: MouseRemote

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [as 别名]
class MouseRemote(AweRemPlugin):
    """
    Print "RedButton Triggered"
    """

    def activate(self):
        self.realMouse = PyMouse()
        self.handler = MouseHandler(self)
        self.info = {"title": "Mouse", "category": "utils",
                     "priority": 0}

    def getHandler(self):
        return self.handler

    def getInfo(self):
        return self.info

    def getIconPath(self, dpi):
        return ""

    def click(self, button, x=None, y=None):
        curx, cury = self.realMouse.position()
        if x is None:
            x = curx
        if y is None:
            y = cury
        self.realMouse.click(x, y, button)

    def press(self, button, x=None, y=None):
        curx, cury = self.realMouse.position()
        if x is None:
            x = curx
        if y is None:
            y = cury
        self.realMouse.press(x, y, button)

    def release(self, button, x=None, y=None):
        curx, cury = self.realMouse.position()
        if x is None:
            x = curx
        if y is None:
            y = cury
        self.realMouse.release(x, y, button)

    def move(self, deltaX, deltaY):
        curx, cury = self.realMouse.position()
        if deltaX is not None:
            curx += deltaX
        if deltaY is not None:
            cury += deltaY
        self.realMouse.move(curx, cury)

    def moveAbsolute(self, x, y):
        self.realMouse.move(x, y)
开发者ID:awerem,项目名称:awerem-computer,代码行数:56,代码来源:mouse.py

示例6: click

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [as 别名]
def click(point):
    """
    Simulates a mouse click

    Args:
        point (int,int) : location (x,y) of the screen to click
    """
    m = PyMouse()
    m.move(*point)
    m.press(*point)
    m.release(*point)
开发者ID:boylea,项目名称:qtbot,代码行数:13,代码来源:robouser.py

示例7: press_left

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [as 别名]
def press_left(t=1.0) :
    m = PyMouse()

    xt=random.randint(1400, 1600)
    yt=random.randint(260, 500)

    m.position()
    m.move(xt, yt)
    time.sleep(0.2)
    m.press(xt, yt)
    time.sleep(t)
    m.release(xt, yt)
开发者ID:chengyake,项目名称:karch,代码行数:14,代码来源:jump.py

示例8: __init__

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [as 别名]
class Player:
    def __init__(self):
        self.mouse = PyMouse()

    def click(self, pos):
        self.mouse.click(*pos)

    def shoot(self, target, power, table_offset, cue_ball):
        adj_target = np.add(target, table_offset)
        self.mouse.press(*adj_target)

        adj_cue = np.add(cue_ball.get_pos(), table_offset)
        self.mouse.drag(*adj_cue)
        self.mouse.release(*adj_cue)
开发者ID:go717franciswang,项目名称:8ball,代码行数:16,代码来源:player.py

示例9: drag

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [as 别名]
def drag(p1, p2, t = 0.05):
    m = PyMouse()
    m.press(p1.x, p1.y, 1)

    x = p1.x
    y = p1.y
    step = 5
    while distance(Point(x, y), p2) >= 1 :
        x += (p2.x - x)/step
        y += (p2.y - y)/step
        step -= 1
        m.drag(x, y)
#        time.sleep(0.01)
    m.release(p2.x, p2.y, 1)
    time.sleep(t)
开发者ID:raichu2652,项目名称:gsync-event-auto,代码行数:17,代码来源:prev.py

示例10: test_event

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [as 别名]
 def test_event(self):
     for size in screen_sizes:
         with Display(visible=VISIBLE, size=size):
             time.sleep(1.0)  # TODO: how long should we wait?
             mouse = PyMouse()
             event = Event()
             event.start()
             # check move
             for p in positions:
                 event.reset()
                 mouse.move(*p)
                 time.sleep(0.01)
                 print('check ', expect_pos(p, size), '=', event.pos)
                 eq_(expect_pos(p, size), event.pos)
             # check buttons
             for btn in buttons:
                 # press
                 event.reset()
                 mouse.press(0, 0, btn)
                 time.sleep(0.01)
                 print("check button", btn, "pressed")
                 eq_(btn, event.button)
                 eq_(True, event.press)
                 # release
                 event.reset()
                 mouse.release(0, 0, btn)
                 time.sleep(0.01)
                 print("check button", btn, "released")
                 eq_(btn, event.button)
                 eq_(False, event.press)
             # check scroll
             def check_scroll(btn, vertical=None, horizontal=None):
                 event.reset()
                 mouse.press(0, 0, btn)
                 time.sleep(0.01)
                 if vertical:
                     eq_(vertical, event.scroll_vertical)
                 elif horizontal:
                     eq_(horizontal, event.scroll_horizontal)
             print("check scroll up")
             check_scroll(4, 1, 0)
             print("check scroll down")
             check_scroll(5, -1, 0)
             print("check scroll left")
             check_scroll(6, 0, 1)
             print("check scroll right")
             check_scroll(7, 0, -1)
             event.stop()
开发者ID:2008820,项目名称:PyUserInput,代码行数:50,代码来源:test_unix.py

示例11: __init__

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

  def __init__(self):
    self.m = PyMouse()
    self.screen = HelperClasses.ScreenClass(self.m.screen_size()[0], self.m.screen_size()[1])
    self.cursor = HelperClasses.CursorClass(self.screen.width/2, self.screen.height/2)

  def moveCursorToCenter(self):
    self.cursor = HelperClasses.CursorClass(self.screen.width/2, self.screen.height/2)
    print "Updated Cursor Position to center of screen (" + str(self.cursor.x) + ", " + str(self.cursor.y) + ")."
    self.moveCursor()

  def moveCursor(self):
    self.m.move(self.cursor.x, self.cursor.y)

  def mousePress(self):
    print "PRESS"
    self.m.press(self.cursor.x, self.cursor.y)

  def mouseRelease(self):
    print "RELEASE"
    self.m.release(self.cursor.x, self.cursor.y)

  def displaceCursor(self, disp):
    # update cursor
    new_x = self.cursor.x + disp.x
    new_y = self.cursor.y + disp.y

    # screen limits
    if new_x > self.screen.width:
      new_x = self.screen.width
    if new_x < 0:
      new_x = 0
    if new_y > self.screen.height:
      new_y = self.screen.height
    if new_y < 0:
      new_y = 0

    actualMovement = HelperClasses.CursorClass(self.cursor.x - new_x, self.cursor.y - new_y)

    self.cursor.x = new_x
    self.cursor.y = new_y
    self.moveCursor()

    return actualMovement
开发者ID:Furkannn,项目名称:senior-design,代码行数:47,代码来源:HostDeviceClass.py

示例12: PyMouse

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

m = PyMouse()
i = 0
while i < 603:
    m.click(30,300,1)
    time.sleep(1)
    m.click(980,515,1)
    time.sleep(1)
    m.click(1125,715,1)
    time.sleep(1)
    m.press(638,94,1)
    time.sleep(1)
    m.release(1395,1055,1)
    time.sleep(1)
    m.click(1135,675)
    time.sleep(1)
    m.click(1825,60)
    time.sleep(1)
    i = i + 1
开发者ID:TehRiehlDeal,项目名称:Screenshot,代码行数:23,代码来源:mouse.py

示例13: Controller

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

	def __init__(self,speed=8):
		self.m = PyMouse()
		self.k = PyKeyboard()
		self.speed = speed*8

		self.xy = {
				'x': 0,
				'y': 0,
				'd_x': 0,
				'd_y': 0,
			}

	def run(self):
		pipe = open('/dev/input/js0','rb')

		try:
			self._move_mouse_thread = Thread(target=self._move_mouse)
			self._move_mouse_thread.start()

			while 1:
				nb = pipe.read(8)
				self._handle(gen_inf(nb))
		except RuntimeError as e:
			raise e

	def _handle(self,inf):
		try:
			if inf['btn'] == 'a_lx':
				self.xy['d_x'] = int(inf['lvl']/self.speed)
			if inf['btn'] == 'a_ly':	
				self.xy['d_y'] = int(inf['lvl']/self.speed)
			if inf['btn'] == 'a_rx':
				self.xy['d_x'] = int(inf['lvl']/(self.speed*4))
			if inf['btn'] == 'a_ry':	
				self.xy['d_y'] = int(inf['lvl']/(self.speed*4))

			if inf['btn'] == 'b_lb' and inf['lvl'] == 1:
				self.m.press(
						x=self.xy['x'],
						y=self.xy['y'],
						button=1,
				)
			elif inf['btn'] == 'b_lb' and inf['lvl'] == 0:
				self.m.release(
						x=self.xy['x'],
						y=self.xy['y'],
						button=1,
				)

			if inf['btn'] == 'b_rb' and inf['lvl'] == 1:
				self.m.press(
						x=self.xy['x'],
						y=self.xy['y'],
						button=2,
				)
			elif inf['btn'] == 'b_rb' and inf['lvl'] == 0:
				self.m.release(
						x=self.xy['x'],
						y=self.xy['y'],
						button=2,
				)
		except RuntimeError as e:
			raise e


	def _move_mouse(self):
		try:
			while 1:
				self.xy['x'] += self.xy['d_x']
				self.xy['y'] += self.xy['d_y']
				self.m.move(
						x=self.xy['x']+self.xy['d_x'],
						y=self.xy['y']+self.xy['d_y'],
				)
				sleep(1/120)
		except RuntimeError as e:
			raise e

	def __del__(self):
		print('Stopping driver...')
开发者ID:ayypot,项目名称:joy2mouse,代码行数:84,代码来源:js.py

示例14: Bot

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import release [as 别名]
class Bot():
    def __init__(self):
        self.mouse = PyMouse()
        self.keyboard = PyKeyboard()
    
    def Delay(self, n):
        time.sleep(n)
    
    """ ====== Mouse Macro ====== """
    def Left_click(self, x, y, n = 1, dl = 0):
        """在屏幕某点左键点击若干次
        """
        self.Delay(dl)
        self.mouse.click(x, y, 1, n)
    
    def Right_click(self, x, y, n = 1, dl = 0):
        """在屏幕某点右键点击若干次
        """
        self.Delay(dl)
        self.mouse.click(x, y, 2, n)
    
    def Double_click(self, x, y, dl = 0):
        """在屏幕的某点双击
        """
        self.Delay(dl)
        self.mouse.click(x, y, 1, n = 2)
    
    def Scroll_up(self, n, dl = 0):
        """鼠标滚轮向上n次
        """
        self.Delay(dl)
        self.mouse.scroll(vertical = n)
    
    def Scroll_down(self, n, dl = 0):
        """鼠标滚轮向下n次
        """
        self.Delay(dl)
        self.mouse.scroll(vertical = -n)
    
    def Move_to(self, x, y, dl = 0):
        """鼠标移动到x, y的坐标处
        """
        self.Delay(dl)
        self.mouse.move(x, y)
    
    def Drag_and_release(self, start, end, dl = 0):
        """从start的坐标处鼠标左键单击拖曳到end的坐标处
        start, end是tuple. 格式是(x, y)
        """
        self.Delay(dl)
        self.mouse.press(start[0], start[1], 1)
        self.mouse.drag(end[0], end[1])
        self.Delay(0.1)
        self.mouse.release(end[0], end[1], 1)
    
    def Screen_size(self):
        width, height = self.mouse.screen_size()
        return width, height
    
    def WhereXY(self):
        x_axis, y_axis = self.mouse.position()
        return x_axis, y_axis
    
    """ ====== Keyboard Macro ====== """
    """COMBINATION组合键"""
    """Ctrl系列"""
    
    def Ctrl_c(self, dl = 0):
        """Ctrl + c 复制
        """
        self.Delay(dl)
        self.keyboard.press_key(self.keyboard.control_key)
        self.keyboard.tap_key("c")
        self.keyboard.release_key(self.keyboard.control_key)
    
    def Ctrl_x(self, dl = 0):
        """Ctrl + x 剪切
        """
        self.Delay(dl)
        self.keyboard.press_key(self.keyboard.control_key)
        self.keyboard.tap_key("x")
        self.keyboard.release_key(self.keyboard.control_key)
        
    def Ctrl_v(self, dl = 0):
        """Ctrl + v 粘贴
        """
        self.Delay(dl)
        self.keyboard.press_key(self.keyboard.control_key)
        self.keyboard.tap_key("v")
        self.keyboard.release_key(self.keyboard.control_key)
    
    def Ctrl_z(self, dl = 0):
        """Ctrl + z 撤销上一次操作
        """
        self.Delay(dl)
        self.keyboard.press_key(self.keyboard.control_key)
        self.keyboard.tap_key("z")
        self.keyboard.release_key(self.keyboard.control_key)
        
    def Ctrl_y(self, dl = 0):
#.........这里部分代码省略.........
开发者ID:windse7en,项目名称:Angora,代码行数:103,代码来源:macro.py

示例15: TestSaisieCarhab

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

#.........这里部分代码省略.........
        self.mouse.click(sceenCoordPoint.x(), sceenCoordPoint.y(), 1)
        
        # Useful to let QGIS processing
        QgsApplication.processEvents()
        
    def clickOnWidget(self, widget):
        '''Click on the given widget.
        
            :param widget: Widget to click on.
            :type widget: QWidget
        '''

        widgetX = widget.rect().center().x()
        widgetY = widget.rect().center().y()
        widgetPos = widget.mapToGlobal(QtCore.QPoint(widgetX, widgetY))
       
        self.moveTo(widgetPos)
        self.mouse.click(widgetPos.x(), widgetPos.y(), 1)
        
        # Useful to let QGIS processing
        QgsApplication.processEvents()
        
    def clickOnWidgetByActionName(self, actionName):
        '''Click on action by its text value.
        
            :param actionName: Text value of the action to click on.
            :type actionName: QString
        '''
        
        button = self.findButtonByActionName(actionName)
        self.clickOnWidget(button)

    def dragAndDropScreen(self, source, dest):
        '''Press mouse at source point, move to destination point and release.
        
            :param source: Drag start position.
            :type source: QPoint
            
            :param dest: Mouse cursor destination point.
            :type dest: QPoint
        '''

        self.moveTo(source)
        self.mouse.press(source.x(), source.y(), 1)
        
        # Useful to let QGIS processing
        QgsApplication.processEvents()

        self.moveTo(dest)
        self.mouse.release(dest.x(), dest.y(), 1)
        
        # Useful to let QGIS processing
        QgsApplication.processEvents()

    def dragAndDropMap(self, source, dest):
        '''DragAndDropScreen in map coordinates.
        
            :param source: Drag start position.
            :type source: QPoint in map coordinates
            
            :param dest: Mouse cursor destination point.
            :type dest: QPoint in map coordinates
        '''
        screenCoordSource = self.mapToScreenPoint(source)
        screenCoordDest = self.mapToScreenPoint(dest)
开发者ID:IGNF,项目名称:saisie_carhab,代码行数:69,代码来源:testSaisieCarhab.py


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