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

Python pyautogui.locateOnScreen函数代码示例

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

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



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

示例1: GetShitDone

def GetShitDone():
    "Tis function looks after the moon and get shit done"
    pos = pyautogui.locateOnScreen('moon.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found moon @ x:', x , ' y:', y)
        pyautogui.click(x, y+75)
        time.sleep( 1.5 )
        pos = pyautogui.locateOnScreen('horn.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'make horn @ x:', x , ' y:', y)
            pyautogui.click(x, y+75)
            return  
        pos = pyautogui.locateOnScreen('pot.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'make pot @ x:', x , ' y:', y)
            pyautogui.click(x, y+75)
            return  
        pos = pyautogui.locateOnScreen('kohl.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'make kohl @ x:', x , ' y:', y)
            pyautogui.click(x, y)
            return 
        pos = pyautogui.locateOnScreen('close.png') 
        if (pos != None):
            x, y = pyautogui.center(pos)       
            print(time.ctime(), 'exit @ x:', x , ' y:', y)
            pyautogui.click(x, y)
            return                   
    return
开发者ID:samularity,项目名称:FoE_Boot,代码行数:33,代码来源:ScreenCapture.py


示例2: buscar_test

def buscar_test():
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    findTest = pyautogui.locateOnScreen('buscar-tests.png')
    if findTest is None:
        msg = 'La opcion LOGIN TO CONSOLE no esta seleccionada'
        return (False, msg)
        #exit(0)
    else:
        testPos = list(findTest)
        #print testPos
         
    centroTest = pyautogui.center(testPos)     
    print centroTest
    pyautogui.moveTo(centroTest)
    pyautogui.click(None,None,1)
    pyautogui.moveRel(10, 30)
    pyautogui.click(None,None,1)
    #pyautogui.screenshot('menu-screen2.png')
    #pyautogui.click(None,None,1)
    #pyautogui.screenshot('menu-screen1.png')
    findLogin = pyautogui.locateOnScreen('imagenx.png')
    print findLogin
    
    return (True, msg)
开发者ID:josem-m,项目名称:pass_test,代码行数:28,代码来源:buscar-tests.py


示例3: for_image_click_left_cornor

def for_image_click_left_cornor(image_path, click = 1):
	try:
		print('MOUSE: Click left cornor on ', image_path, ' for ', click)
		if gui.locateOnScreen(image_path) != None:
			x, y, x2, y2 = gui.locateOnScreen(image_path)
			mouse.moveTo(x, y)
			while(click > 0):
				print('\tclicked')
				mouse.click()
				click -= 1
	except Exception as e:
		gui.alert("Failed: " + str(e))
		print(e)
开发者ID:zero41120,项目名称:PourmandLab,代码行数:13,代码来源:channel_tracker.py


示例4: facebookPost

	def facebookPost(self):
		self.gotoWeb(-1,'www.facebook.com')
		time.sleep(3)
		pag.press('p')
		currentTime = '{:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now())
		context = 'Hello, facebook!\n\nSent from Music: Project -- ' + currentTime+'\n'
		pag.typewrite(context, interval=0.2)
		loc = pag.locateOnScreen('./post_zh.png')
		if loc:
			pos = pag.center(loc)
			pag.click(pos[0]/2, pos[1]/2)
		else:
			pos = pag.center(pag.locateOnScreen('./post.png'))
			pag.click(pos[0]/2, pos[1]/2)
开发者ID:gdoggg2032,项目名称:MSAR,代码行数:14,代码来源:actor_beta.py


示例5: makeOrder

def makeOrder(orderType):
    """Does the mouse clicks needed to create an order.

    The orderType parameter has the value of one of the ONIGIRI, GUNKAN_MAKI, CALIFORNIA_ROLL, SALMON_ROLL, SHRIMP_SUSHI, UNAGI_ROLL, DRAGON_ROLL, COMBO constants.

    The INVENTORY global variable is updated in this function for orders made.

    The return value is None for a successfully made order, or the string of an ingredient constant if that needed ingredient is missing."""
    global ROLLING_COMPLETE, INGRED_COORDS, INVENTORY

    # wait until the mat is clear. The previous order could still be there if the conveyor belt has been full or the mat is currently rolling.
    while time.time() < ROLLING_COMPLETE and pyautogui.locateOnScreen(imPath('clear_mat.png'), region=(GAME_REGION[0] + 115, GAME_REGION[1] + 295, 220, 175)) is None:
        time.sleep(0.1)

    # check that all ingredients are available in the inventory.
    for ingredient, amount in RECIPE[orderType].items():
        if INVENTORY[ingredient] < amount:
            logging.debug('More %s is needed to make %s.' % (ingredient, orderType))
            return ingredient

    # click on each of the ingredients
    for ingredient, amount in RECIPE[orderType].items():
        for i in range(amount):
            pyautogui.click(INGRED_COORDS[ingredient], duration=0.25)
            INVENTORY[ingredient] -= 1
    findAndClickPlatesOnBelt() # get rid of any left over meals on the conveyor belt, which may stall this meal from being loaded on the belt
    pyautogui.click(MAT_COORDS, duration=0.25) # click the rolling mat to make the order
    logging.debug('Made a %s order.' % (orderType))
    ROLLING_COMPLETE = time.time() + 1.5 # give the mat enough time (1.5 seconds) to finish rolling before being used again
开发者ID:flow0787,项目名称:python,代码行数:29,代码来源:sushigoroundbot.py


示例6: output_doulist

def output_doulist(input_list):
    # 1. find button and change focus in browser
    button_pos = pyautogui.locateOnScreen('output/add_button.png')
    if not button_pos: 
        # no valid button        
        print '没有找到有效的"添加内容"按钮, 请检查后再次导出.'
        return
    elif len(list(pyautogui.locateAllOnScreen('output/add_button.png'))) > 1:
        # more than one valid button
        print '屏幕中有多个有效的"添加内容"按钮, 请检查后再次导出.'
        return
    else:
        # valid input: only one button available
        # remaining issue: the picture is not alwas found in screen...that's strange.
        pyautogui.click(button_pos)
    for i in input_list:
        # 2. press button 
        time.sleep(4)
        pyautogui.click(button_pos)
        # 3. write link
        time.sleep(2)
        pyautogui.typewrite(i)
        pyautogui.press('enter')
        # 4. add to Doulist
        time.sleep(2)
        pyautogui.press('tab')
        pyautogui.press('tab')
        pyautogui.press('tab')
        pyautogui.press('enter')
    print 'iDoulist: 书籍列表已被添加到屏幕上的豆列中.'
开发者ID:chaonet,项目名称:iDoulist,代码行数:30,代码来源:function2_output.py


示例7: buscar_campo_id

def buscar_campo_id():
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    dondeEstaElCampoID = pyautogui.locateOnScreen('operator-id-field.png')
    if dondeEstaElCampoID is None:
        msg = 'El campo de OPERATOR-ID no fue encontrado'
        return (False, msg)
        
    else:
        campoIDPos = list(dondeEstaElCampoID)
        #print campoIDPos
         
    centrocampoID = pyautogui.center(campoIDPos)     
    #print centrocampoID
    pyautogui.moveTo(centrocampoID)
    pyautogui.click(None,None,2)
    pyautogui.typewrite('operador1')
    pyautogui.press('enter')
    pyautogui.press('enter')
    pyautogui.press('enter')
    
    
    
    return (True, msg)
开发者ID:josem-m,项目名称:dena,代码行数:27,代码来源:main_find_pass-oct-21-15-original.py


示例8: find_game_region

def find_game_region():
    """
    Uses image inactive_window.png to find the coordinates of the game
    Inputs: None
    Outputs: the tuple of the coordinates of the game window
    """
    logging.debug("About to take a screenshot and look for inactive_window.png")
    coors = pyautogui.locateOnScreen("images/inactive_window.png")
    if coors is None:
        logging.debug("Did not find inactive_window.png")
        logging.debug("Maybe the window is active instead. Will look for active_window.png")
        coors = pyautogui.locateOnScreen("images/active_window.png")
        if coors is None:
            raise Exception("The game as not found on this screen. Make sure it is visible.")
    logging.debug("Successfully found the game region: " + str(coors[0],coors[1]))
    return (coors[0],coors[1])
开发者ID:hydrophilicsun,项目名称:Automating-Minesweeper-,代码行数:16,代码来源:main.py


示例9: navigateStartGameMenu

def navigateStartGameMenu():
	"""Performs the clicks to navigate from the start screen (where the PLAY button is visible) to the beginning 
	of the first level."""
    # Click on everything needed to get past the menus at the start of the game.
	
	# Click on PLAY
	logging.debug('Looking for Play button...')
	while True: # loop because it could be the blue or ping Play button displayed (blinking)
		pos = pyautogui.locateOnScreen(imPath('play_button.png'), region=GAME_REGION)
		if pos is not None:
			break
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked Play button.')

	# click on Continue
	pos = pyautogui.locateCenterOnScreen(imPath('continue_button.png'), region=GAME_REGION)
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked on Continue button.')

	# click on Skip
	logging.debug('Looking for Skip button...')
	while True: # loop because it could be the yellow or red Skip button displayed (blinking)
		pos = pyautogui.locateCenterOnScreen(imPath('skip_button.png'), region=GAME_REGION)
		if pos is not None:
			break
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked on Skip button.')

	# click on Continue
	pos = pyautogui.locateCenterOnScreen(imPath('continue_button.png'), region=GAME_REGION)
	pyautogui.click(pos, duration=0.25)
	logging.debug('Clicked Continue button.')
开发者ID:flow0787,项目名称:python,代码行数:32,代码来源:suhigoround.py


示例10: __init__

 def __init__(self):
     self.osk = pyautogui.locateOnScreen('data/osk.png')
     if self.osk is None:
         raise NoKeyboardException()
     self.time_created = time.time()
     self.hp_pots_used = 0
     self.mana_pots_used = 0
开发者ID:omgimanerd,项目名称:python-maplestory-bot,代码行数:7,代码来源:Bot.py


示例11: buscar_campo_serial

def buscar_campo_serial(serial_number):
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    dondeEstaElCampoSerial = pyautogui.locateOnScreen('operator-id-field.png')
    if dondeEstaElCampoSerial is None:
        msg = 'El campo de SERIAL NUMBER no fue encontrado'
        return (False, msg)
        
    else:
        campoSerialPos = list(dondeEstaElCampoSerial)
        #print campoSerialPos
         
    centrocampoSerial = pyautogui.center(campoSerialPos)     
    #print centrocampoSerial
    pyautogui.moveTo(centrocampoSerial)
    pyautogui.click(None,None,2)
    #pyautogui.typewrite('C3WB4E768226230')
    pyautogui.typewrite(serial_number)
    pyautogui.press('enter')
    #pyautogui.press('enter')
    #pyautogui.press('enter')
    
    return (True, msg)
开发者ID:josem-m,项目名称:dena,代码行数:26,代码来源:main_find_pass-oct-21-15-original.py


示例12: hangup

def hangup():
    location = pyautogui.locateOnScreen(image('hangup.png'))
    if location is None:
        print 'Could not find hangup button'
        return False
    location_x, location_y = pyautogui.center(location)
    pyautogui.click(location_x, location_y)
    time.sleep(3)
开发者ID:pdxjohnny,项目名称:hangouts-caller,代码行数:8,代码来源:hangouts.py


示例13: GetTheResources

def GetTheResources():
    "Tis function grabs a frame and click below the hammer"
    pos = pyautogui.locateOnScreen('hammer.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found hammer @ x:', x , ' y:', y)
        pyautogui.click(x, y+100)
    return
开发者ID:samularity,项目名称:FoE_Boot,代码行数:8,代码来源:ScreenCapture.py


示例14: GetTheArmy

def GetTheArmy():
    "Tis function grabs a frame and click below the hammer"
    pos = pyautogui.locateOnScreen('schwert.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found sword @ x:', x , ' y:', y)
        pyautogui.click(x, y+75)
    return
开发者ID:samularity,项目名称:FoE_Boot,代码行数:8,代码来源:ScreenCapture.py


示例15: GetTheMoney

def GetTheMoney():
    "Tis function grabs a frame and click below the coin"
    pos = pyautogui.locateOnScreen('geld.png') 
    if (pos != None):
        x, y = pyautogui.center(pos)       
        print(time.ctime(), 'Found coin @ x:', x , ' y:', y)
        pyautogui.click(x, y+55)
    return
开发者ID:samularity,项目名称:FoE_Boot,代码行数:8,代码来源:ScreenCapture.py


示例16: run

	def run(self):		
		if (self.ws == 0):
				self.showErrMsg.emit(u'錯誤', u'請選取有效檔案')

		else:
			start=1
			count = 0
			while start:
				sleep(1)
				count += 1
				trigger  = None
				trigger1 = locateOnScreen('./img/det1.png')
				trigger2 = locateOnScreen('./img/det2.png')
				trigger3 = locateOnScreen('./img/det3.png')
				detStr = u'狀態:  偵測中.{0}'

				self.addStatus.emit( detStr.format('.'*(count%4)), 0)
				if   trigger1 != None:
					trigger = trigger1
				elif trigger2 != None:
					trigger = trigger2
				elif trigger3 != None:
					trigger = trigger3
				else:
					if self.stopSign == 1:
						start = 0
						self.addStatus.emit( u'狀態:  手動終止偵測程序', 1)
					else:
						self.addStatus.emit( u'狀態:  偵測不到輸入區域', 0)

				if trigger != None:
					self.addStatus.emit( u'狀態:  偵測到輸入區域', 9)
					self.toTray.emit(1)
					start = 0
					moveToX = (trigger[0]+trigger[2])
					moveToY = (trigger[1]+trigger[3])
					click(x=moveToX, y=moveToY, clicks=1, interval=0, button='left') 
					self.wswrite(self.ws)
					if self.stopSign == 1:
						self.addStatus.emit( u'狀態:  手動終止輸入程序', 1)
					else:
						self.threadDone.emit()
						self.toTray.emit(0)
		self.enableButtons.emit()
		return 0
开发者ID:s910324,项目名称:AutoSchedule,代码行数:45,代码来源:AutoSchedule.py


示例17: checkMana

 def checkMana(self, pot_key):
     """
     Given a key that is bound to a mana potion, this method will check for a
     depleted mana bar and use potions until it can no longer see a depleted
     mana bar.
     """
     while not pyautogui.locateOnScreen('data/mana.png'):
         self.click(pot_key, 0.25)
         self.mana_pots_used += 1
开发者ID:omgimanerd,项目名称:python-maplestory-bot,代码行数:9,代码来源:Bot.py


示例18: checkHealth

 def checkHealth(self, pot_key):
     """
     Given a key that is bound to a health potion, this method will check
     for a depleted health bar and use potions until it can no longer see a
     depleted health bar.
     """
     while not pyautogui.locateOnScreen('data/hp.png'):
         self.click(pot_key, 0.25)
         self.hp_pots_used += 1
开发者ID:omgimanerd,项目名称:python-maplestory-bot,代码行数:9,代码来源:Bot.py


示例19: checkForGameOver

def checkForGameOver():
    """Checks the screen for the "You Win" or "You Fail" message.

    On winning, returns the string in LEVEL_WIN_MESSAGE.

    On losing, the program terminates."""

    # check for "You Win" message
    result = pyautogui.locateOnScreen(imPath('you_win.png'), region=(GAME_REGION[0] + 188, GAME_REGION[1] + 94, 262, 60))
    if result is not None:
        pyautogui.click(pyautogui.center(result))
        return LEVEL_WIN_MESSAGE

    # check for "You Fail" message
    result = pyautogui.locateOnScreen(imPath('you_failed.png'), region=(GAME_REGION[0] + 167, GAME_REGION[1] + 133, 314, 39))
    if result is not None:
        logging.debug('Game over. Quitting.')
        sys.exit()
开发者ID:flow0787,项目名称:python,代码行数:18,代码来源:sushigoroundbot.py


示例20: pass_search

def pass_search():
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy("")

    dondeEstaElBoton = pyautogui.locateOnScreen("go-button.png")
    if dondeEstaElBoton is None:
        print "El boton de GO no fue encontrado"

    else:
        botonPos = list(dondeEstaElBoton)
        print botonPos

    centroBoton = pyautogui.center(botonPos)
    print centroBoton

    contador = 0
    while True:
        contador += 1
        pyautogui.moveTo(centroBoton)
        pyautogui.moveRel(796, 0)  # Mover el raton a la barra de desplazamiento
        pyautogui.click(None, None, 2)
        # if contador == 1:
        #    time.sleep(0.3)
        #    pyautogui.typewrite('!reset')
        #    pyautogui.press('enter')

        pyautogui.click(None, None, 1)
        pyautogui.dragRel(0, -293, 1, button="left")
        # pyautogui.scroll(10)  #Hacer scroll para llegar a la parte superior del cuadro de texto
        # pyautogui.moveRel(0, -294)   #Mover el raton a la parte superior de la barra de desplazamiento
        pyautogui.moveRel(-390, 0)  # Mover el raton a la posicion en donde se encuentra la clave

        pyautogui.PAUSE = 0.05

        pyautogui.click(None, None, 2)
        # pyautogui.doubleClick()   #Hacer dobleclic en la palabra de la clave
        pyautogui.hotkey("ctrl", "c")

        # pyautogui.doubleClick()   #Hacer dobleclic en la palabra de la clave
        # pyautogui.hotkey('ctrl', 'c')

        # pyautogui.doubleClick()   #Hacer dobleclic en la palabra de la clave
        # pyautogui.hotkey('ctrl', 'c')
        pyautogui.PAUSE = 1

        r = pyperclip.paste()
        print r

        if len(r) == 10:
            print "clave encontrada"
            break
        if contador == 5:
            print "Se hizo el intento 5 veces para buscar la clave"
            break
        time.sleep(0.5)
开发者ID:josem-m,项目名称:pass_test,代码行数:56,代码来源:lv-mani.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pyautogui.moveRel函数代码示例发布时间:2022-05-25
下一篇:
Python pyautogui.keyUp函数代码示例发布时间: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