• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyautogui.position函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyautogui.position函数的典型用法代码示例。如果您正苦于以下问题:Python position函数的具体用法?Python position怎么用?Python position使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_moveRel

    def test_moveRel(self):
        # start at the center
        desired = self.center
        pyautogui.moveTo(*desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move down and right
        desired += P(42, 42)
        pyautogui.moveRel(42, 42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move up and left
        desired -= P(42, 42)
        pyautogui.moveRel(-42, -42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move right
        desired += P(42, 0)
        pyautogui.moveRel(42, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move down
        desired += P(0, 42)
        pyautogui.moveRel(None, 42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move left
        desired += P(-42, 0)
        pyautogui.moveRel(-42, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # move up
        desired += P(0, -42)
        pyautogui.moveRel(None, -42)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a list instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel([42, 42])
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a tuple instead of separate x and y.
        desired -= P(42, 42)
        pyautogui.moveRel((-42, -42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a sequence-like object instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveRel(P(42, 42))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)
开发者ID:csampaio,项目名称:screen2text,代码行数:60,代码来源:autoguitest.py


示例2: main

def main():

	while True:
        	position = pyautogui.position()
		time.sleep(60)
		if position == pyautogui.position():
			pyautogui.moveRel(0,-1)
			pyautogui.moveRel(0,1)
开发者ID:dallanwagz,项目名称:py-hax,代码行数:8,代码来源:movemouse.py


示例3: Start

def Start(pos):
    pyautogui.FAILSAFE = False
    global root, running
    im=pyautogui.screenshot()
    pos['text']=str(pyautogui.position())
    rgb['text']=str(im.getpixel(pyautogui.position()))
    root.update_idletasks()
    root.after(10, lambda:Start(pos))
开发者ID:tushutripathi,项目名称:posRGB,代码行数:8,代码来源:posRGB.py


示例4: func

        def func():
            self.screenshot_button.config(state='disabled')

            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Deselect the game window %s' % second)
                if second != 0:
                    time.sleep(1)

            region = []
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place the mouse at the top left\nof the game\'s title bar %s' % second)
                if second != 0:
                    time.sleep(1)
            constant_top_left = pyautogui.position()
            region.extend(constant_top_left)
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place the mouse at the bottom right\nof the game\'s title bar %s' % second)
                if second != 0:
                    time.sleep(1)
            constant_bottom_right = pyautogui.position()
            region.extend(
                (constant_bottom_right[0] - constant_top_left[0],
                 constant_bottom_right[1] - constant_top_left[1])
            )
            self.deselected_screenshot = pyautogui.screenshot(region=region)
            pyautogui.click()
            self.selected_screenshot = pyautogui.screenshot(region=region)

            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place mouse at the top left\nof the entire game window %s' % second)
                if second != 0:
                    time.sleep(1)
            top_left = pyautogui.position()
            for second in reversed(range(4)):
                self.screenshot_label.config(
                    text='Place mouse at the bottom right\nof the entire game window %s' % second)
                if second != 0:
                    time.sleep(1)
            bottom_right = pyautogui.position()

            self.screen_size = [
                constant_top_left[0] - top_left[0],
                constant_top_left[1] - top_left[1],
                bottom_right[0] - constant_bottom_right[0],
                bottom_right[1] - constant_bottom_right[1]
            ]

            self.screenshot_taken = True
            self.screenshot_label.config(text='Screenshot Taken')
            self.screenshot_button.config(
                state='normal', text='Retake Screenshot')
开发者ID:jaronoff97,项目名称:play_as_one,代码行数:55,代码来源:PlayAsOne.py


示例5: v_scroll_on_android

def v_scroll_on_android(scroll_value=20, locate_first_on_center = True, scrollDown = True):
    # Locate the mouse on screen center
    if(locate_first_on_center is True):
        locate_on_center()
    # Simulate drag and drop
    # pyautogui.mouseDown();
    x, y = pyautogui.position()[0], pyautogui.position()[1]
    if(scrollDown is True):
        y = y - scroll_value;
    else:
        y = y + scroll_value;
    pyautogui.dragTo(x, y)
开发者ID:g-sari,项目名称:py-mario-ai,代码行数:12,代码来源:utils.py


示例6: showLocation

	def showLocation():
		lastLoc = (0,0)
		newLoc = (1,0)
		while lastLoc !=  newLoc:
			x, y = pyautogui.position()
			time.sleep(0.25)
			locX.delete(0,END)
			locY.delete(0,END)
			locX.insert(0,x)
			locY.insert(0,y)
			lastLoc = newLoc
			newLoc = pyautogui.position()
开发者ID:Box-Of-Hats,项目名称:Py-Macro,代码行数:12,代码来源:MacroRecorderApplication.py


示例7: onClick

	def onClick(self, mouse_button):
		if mouse_button == 4: #scroll up
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(1)
			pyautogui.moveTo(*prev, pause=False)
		elif mouse_button == 5: #scroll dn
			prev = pyautogui.position()
			pyautogui.moveTo(0, pyautogui.size()[1], pause=False)
			pyautogui.scroll(-1)
			pyautogui.moveTo(*prev, pause=False)
		else: #do nothing
			pass
开发者ID:MCManuelLP,项目名称:dotfiles,代码行数:13,代码来源:status_base.py


示例8: test_position

    def test_position(self):
        mousex, mousey = pyautogui.position()

        self.assertTrue(isinstance(mousex, int), 'Type of mousex is %s' % (type(mousex)))
        self.assertTrue(isinstance(mousey, int), 'Type of mousey is %s' % (type(mousey)))

        # Test passing x and y arguments to position().
        pyautogui.moveTo(mousex + 1, mousey + 1)
        x, y = pyautogui.position(mousex, None)
        self.assertEqual(x, mousex)
        self.assertNotEqual(y, mousey)

        x, y = pyautogui.position(None, mousey)
        self.assertNotEqual(x, mousex)
        self.assertEqual(y, mousey)
开发者ID:asweigart,项目名称:pyautogui,代码行数:15,代码来源:test_pyautogui.py


示例9: auto_mouse

def auto_mouse():
	auto.moveTo(450,450)
	pos = auto.position()

	auto.moveRel(-200,-200)
	pos2  = auto.position()
	for i in range(100 ):
		try:
			auto.moveTo(pos, duration = 1, tween = auto.easeInCubic)
			auto.click()
			auto.moveTo(pos, duration = 1)
			auto.click()
			auto.moveTo(pos2,duration = 1, tween = auto.easeInQuad)
		except:
			sys.exit()
开发者ID:arhik,项目名称:NuLocale,代码行数:15,代码来源:mouse_automation.py


示例10: test_moveTo

    def test_moveTo(self):
        # moving the mouse
        desired = self.center
        pyautogui.moveTo(*desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # no coordinate specified (should be a NO-OP)
        pyautogui.moveTo(None, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # moving the mouse to a new location
        desired += P(42, 42)
        pyautogui.moveTo(*desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # moving the mouse over time (1/5 second)
        desired -= P(42, 42)
        pyautogui.moveTo(desired.x, desired.y, duration=0.2)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # moving the mouse with only x specified
        desired -= P(42, 0)
        pyautogui.moveTo(desired.x, None)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # ...and only y specified
        desired -= P(0, 42)
        pyautogui.moveTo(None, desired.y)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a list instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveTo(list(desired))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a tuple instead of separate x and y.
        desired += P(42, 42)
        pyautogui.moveTo(tuple(desired))
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)

        # Passing a sequence-like object instead of separate x and y.
        desired -= P(42, 42)
        pyautogui.moveTo(desired)
        mousepos = P(*pyautogui.position())
        self.assertEqual(mousepos, desired)
开发者ID:csampaio,项目名称:screen2text,代码行数:53,代码来源:autoguitest.py


示例11: clickAndReturnMouseCoords

def clickAndReturnMouseCoords(coords):
    orig_x,orig_y = pyautogui.position()
    pyautogui.moveTo(coords[0],coords[1])
    pyautogui.click()
    logging.info('CLICK')
    pyautogui.moveTo(orig_x, orig_y)
    return
开发者ID:starcraft04,项目名称:swauto,代码行数:7,代码来源:functions_opencv.py


示例12: initialize

def initialize():
    if not os.getenv('GOOGLE_API_KEY'):
        print('*' * 80)
        print('You must set GOOGLE_API_KEY to OS environments.')
        print('Please check https://developers.google.com/maps/documentation/javascript/get-api-key')
        print("export GOOGLE_API_KEY='blahblah' to ~/.bash_profile")
        print('*' * 80)
        raise NameError('GOOGLE_API_KEY')

    print("Cursor on GPS button of xcode.")
    input("press enter to continue")
    gps_button_pos = pyautogui.position()
    print("Cursor on GPX file of xcode. (pikapika.gpx)")
    input("press enter to continue")
    gpx_file_pos = pyautogui.position()
    return gps_button_pos, gpx_file_pos
开发者ID:Ipukema,项目名称:PokemonGoWithMap,代码行数:16,代码来源:runserver.py


示例13: clickAndReturnMouse_point

def clickAndReturnMouse_point(point):
    orig_x,orig_y = pyautogui.position()
    pyautogui.moveTo(point['center'][0],point['center'][1])
    pyautogui.click()
    logging.info('CLICK')
    pyautogui.moveTo(orig_x, orig_y)
    return
开发者ID:starcraft04,项目名称:swauto,代码行数:7,代码来源:functions_opencv.py


示例14: __init__

 def __init__(self,mag=100, browser='Firefox'):
     top_bar = {'Firefox':100,'Chrome':115}
     self.__x, self.__y = position()
     self.__top_bar = top_bar[browser]
     self.__y -= top_bar[browser]
     self.__center = False
     self.__mag = mag
开发者ID:xenialenvy,项目名称:Agarbot,代码行数:7,代码来源:Blob.py


示例15: test

def test():
    i = 0
    while i < 5:
        i = i + 1
        print pyautogui.position()
        #window = pyautogui.locateCenterOnScreen('wood.png')
        windows = pyautogui.locateAllOnScreen('key.png')
        #if window is None:
        #    sys.exit('Could not find game on screen. Is the game visible?')
        for window in windows:
            l = window[0]
            t = window[1]
            w = window[2]
            h = window[3]
            time.sleep(0.1)
            pyautogui.moveTo(l+w/2, t+h/2)
开发者ID:Baart,项目名称:py,代码行数:16,代码来源:autobot.py


示例16: clickAndReturnMouse

def clickAndReturnMouse(img):
    orig_x,orig_y = pyautogui.position()
    pyautogui.moveTo(img['points'][0]['center'][0],img['points'][0]['center'][1])
    pyautogui.click()
    logging.info('CLICK')
    pyautogui.moveTo(orig_x, orig_y)
    return
开发者ID:starcraft04,项目名称:swauto,代码行数:7,代码来源:functions_opencv.py


示例17: keysGui

def keysGui(cmdKeys,changeVar):

	def loadKey(lb,changeVar):
		keyToLoad = int(lb.curselection()[0])
		keyStr = cmdKeys[keyToLoad]
		changeVar.delete(0,'end')
		changeVar.insert(0,keyStr)
		rootC.destroy()

	rootC = Tk()
	scrollbar2 = Scrollbar(rootC)
	scrollbar2.pack(side=RIGHT,fill=BOTH)
	listbox2 = Listbox(rootC, yscrollcommand=scrollbar2.set,width=40)
	scrollbar2.config(command=listbox2.yview)

	for keyK in cmdKeys:
		listbox2.insert(END,str(keyK))

	def clickEvent(event):
		try:
			loadKey(listbox2,changeVar)
		except IndexError:
			pass

	currentMousePos = pyautogui.position()

	listbox2.pack(fill=BOTH,expand=1,side=LEFT)
	rootC.geometry('{}x{}+{}+{}'.format(320, 430,(currentMousePos[0]-155),currentMousePos[1]-185))
	rootC.bind("<Button-1>", clickEvent)
	rootC.wm_attributes("-topmost",int(True))
	rootC.wm_title("List Of Keys")
	rootC.mainloop()
开发者ID:Box-Of-Hats,项目名称:Py-Macro,代码行数:32,代码来源:MacroRecorderApplication.py


示例18: main

def main():
    global base_lat, base_lon

    print("(1/3)GPS button에 커서를 올려주세요.")
    input("완료되었으면 엔터를 눌러주세요.")

    xcode_gps_button_loc = pyautogui.position()
    print("\n(2/3)GPX file에 커서를 올려주세요.")
    input("완료되었으면 엔터를 눌러주세요.")

    xcode_gpx_file_loc = pyautogui.position()
    print("\n(3/3)터미널에 커서를 올려주세요.")
    input("완료되었으면 엔터를 눌러주세요.")
    terminal_loc = pyautogui.position()

    success, base_lat, base_lon = load_save()
    if success:
        print("\n저장파일에서 좌표값을 자동으로 불러왔습니다.")
    else:
        print("\n저장파일에서 좌표값 불러오기를 실패했습니다.")

    print("\n끝! wasd로 움직이고 cmd + c로 종료하세요.\n좌표가 바뀔 때마다 자동으로 저장됩니다.")
    lat = 0
    lon = 0
    # 인터럽트가 없는 한 아래를 무한반복한다.
    while True:
        k = input_manager()
        if k == 'w':
            lat += 1
        elif k == 'd':
            lon += 1
        elif k == 's':
            lat -= 1
        elif k == 'a':
            lon -= 1
        # gpx 파일 생성
        gen_gpx(lat, lon)
        # gps 버튼 클릭
        pyautogui.moveTo(xcode_gps_button_loc)
        pyautogui.click()
        # gpx 클릭
        pyautogui.moveTo(xcode_gpx_file_loc)
        pyautogui.click()
        # 터미널 클릭
        pyautogui.moveTo(terminal_loc)
        pyautogui.click()
    return
开发者ID:cjeon,项目名称:sokChoGo,代码行数:47,代码来源:sokchogo.py


示例19: real_change

 def real_change(lat_lng_string):
     if js_develop_mode:
         return
     last_pos = pyautogui.position()
     lat_lng = dict(re.findall(r'([latng]{3})\=([\d\.\-]+)', lat_lng_string))
     rewrite_gpx(lat_lng)
     for pos in gps_button_pos, gpx_file_pos, last_pos:
         pyautogui.click(*pos)
开发者ID:Ipukema,项目名称:PokemonGoWithMap,代码行数:8,代码来源:runserver.py


示例20: grava

def grava():
    pos = input("Quantas posiçoes deseja salvar?")
    sec = input("Delay")

    for i in range(pos):
        print("Gravando %dª posiçao" % (i))
        posicoes.append(pyautogui.position())
        time.sleep(sec)
开发者ID:Fnandoz,项目名称:AutoClick,代码行数:8,代码来源:AutoClick-0.1.1.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyautogui.press函数代码示例发布时间:2022-05-25
下一篇:
Python pyautogui.moveTo函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap