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


Python pyautogui.locateOnScreen函数代码示例

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


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


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