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


Python PyMouse.position方法代码示例

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


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

示例1: Robot

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

示例2: move_down

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

示例3: showMouseLoc

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import position [as 别名]
	def showMouseLoc(self):
		try:
			m = PyMouse() # make mouse object
			while(1):
				print m.position() # print the position
		except KeyboardInterrupt:
			pass
开发者ID:thewill2live,项目名称:Sample_Code_Python,代码行数:9,代码来源:SpartanSmartBoard.py

示例4: run

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import position [as 别名]
    def run(self):
        global mself
        global runflag
        
        m = PyMouse()

        #raw_input("请先将鼠标移动到数据位置的左上角,然后按下回车.")
        wx.MessageBox("请不要点击该对话框的确定按钮\n先将鼠标移动到数据位置的左上角,然后按下回车...", "获取数据位置", wx.OK)
        p1 = m.position()
        print p1
        #raw_input("接下来将鼠标移动到数据位置的右下角,然后按下回车.")
        wx.MessageBox("接下来将鼠标移动到数据位置的右下角,然后按下回车...", "获取数据位置", wx.OK)
        p2 =  m.position()
        print p2
        print "完成数据位设定,开始获取数据工作."
        imbox = (p1[0], p1[1], p2[0], p2[1])

        prev_s = [0,0,0,0]
        while runflag:
            try:
                im = ImageGrab.grab(imbox)
                s = image_to_string(im)
                s = s.split()
                if s != prev_s and len(s)==4 :
                    sell =  float(s[0]) - float(prev_s[0])
                    buy = float(s[2]) - float(prev_s[2])
                    prev_s = s

                    print sell, buy
                    mself.staticText1.SetLabel(mself.staticText2.GetLabel())
                    mself.staticText2.SetLabel(mself.staticText3.GetLabel())
                    mself.staticText3.SetLabel(mself.staticText4.GetLabel())
                    mself.staticText4.SetLabel(mself.staticText5.GetLabel())
                    mself.staticText5.SetLabel(mself.staticText6.GetLabel())
                    mself.staticText6.SetLabel(mself.staticText7.GetLabel())
                    mself.staticText7.SetLabel(mself.staticText8.GetLabel())
                    mself.staticText8.SetLabel(mself.staticText9.GetLabel())
                    mself.staticText9.SetLabel(mself.staticText10.GetLabel())
                    mself.staticText10.SetLabel("%.1f"%sell)

                    mself.staticText11.SetLabel(mself.staticText12.GetLabel())
                    mself.staticText12.SetLabel(mself.staticText13.GetLabel())
                    mself.staticText13.SetLabel(mself.staticText14.GetLabel())
                    mself.staticText14.SetLabel(mself.staticText15.GetLabel())
                    mself.staticText15.SetLabel(mself.staticText16.GetLabel())
                    mself.staticText16.SetLabel(mself.staticText17.GetLabel())
                    mself.staticText17.SetLabel(mself.staticText18.GetLabel())
                    mself.staticText18.SetLabel(mself.staticText19.GetLabel())
                    mself.staticText19.SetLabel(mself.staticText20.GetLabel())
                    mself.staticText20.SetLabel("%.1f"%buy)

                im.save("show.jpg")
                pic=wx.Image("show.jpg")
                w,h = mself.staticBitmap1.GetSize()
                mself.staticBitmap1.SetBitmap(pic.Rescale(w,h).ConvertToBitmap())
            except:
                traceback.print_exc()
                wx.MessageBox("无法正常识别,请重新开始.注意数据截取位置.", "提醒", wx.OK)
                runflag = 0
开发者ID:taojy123,项目名称:sinyee_show,代码行数:61,代码来源:Frame1.py

示例5: MouseRemote

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

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

示例7: show_mouse_position

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import position [as 别名]
def show_mouse_position():
    # import the module
    from pymouse import PyMouse
    m = PyMouse()
    m.move(200, 200)

    # click works about the same, except for int button possible values are 1: left, 2: right, 3: middle
    m.click(500, 300, 1)

    # get the screen size
    m.screen_size()
    # (1024, 768)

    # get the mouse position
    m.position()
开发者ID:kamekame,项目名称:alpha,代码行数:17,代码来源:f.py

示例8: grabbing_screen

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import position [as 别名]
def grabbing_screen(tmp_dir, number_pages=None, cmp_pages_after=None):
    """
        grabbing screen, paging and yield images

            number_pages - count pages for grabbing
            cmp_images_after - after that count pages current page and previous page will be compared,
                                and if they will be equal function stoped
    """
    from pymouse import PyMouse

    m = PyMouse()
    grab_coords = []

    raw_input("Set mouse to up left corner and press enter...")
    grab_coords += list(m.position())

    raw_input("Set mouse to down left corner and press enter...")
    grab_coords += list(m.position())

    grab_coords[2] -= grab_coords[0]
    grab_coords[3] -= grab_coords[1]

    grab_coords = map(lambda x: str(int(x)), grab_coords)

    raw_input("Set mouse to position for paging and press enter")
    paging_coords_args = list(m.position()) + [1]

    def make_screenshot(coords, filename):
        command = "screencapture -R%s %s" % (','.join(coords), filename)
        os.system(command)

    for i in xrange(number_pages):
        current_page_image = image_page(tmp_dir, i)

        make_screenshot(grab_coords, current_page_image)
        m.click(*paging_coords_args)
        time.sleep(1)

        if not i % 10:
            print 'grabing page #%d' % i

        if i > cmp_pages_after:
            prev_image = image_page(tmp_dir, i - 1)
            if filecmp.cmp(current_page_image, prev_image):
                os.system("rm %s" % current_page_image)
                break

        yield current_page_image
开发者ID:toly,项目名称:books_grabbing,代码行数:50,代码来源:grab.py

示例9: test_move

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

示例10: __init__

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

示例11: __init__

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

    def __init__(self):
        self.mouse = PyMouse()

    def recv(self):
        return self.mouse.position()
开发者ID:menuojo,项目名称:dev_python,代码行数:9,代码来源:sendmouseposition.py

示例12: test_move

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

示例13: ut_showMouseLoc

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

示例14: test_move

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

示例15: zoom_out

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import position [as 别名]
def zoom_out():
    m = PyMouse()
    (x, y) = m.position()
    m.move(700, 700)
    press()
    # m.move(200, 100)
    # m.move(300, 100)
    # m.move(400, 100)
    # m.move(500, 100)
    release()
开发者ID:andredalton,项目名称:kmlogger,代码行数:12,代码来源:screen.py


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