How to use the pyautogui.locateCenterOnScreen function in PyAutoGUI

To help you get started, we’ve selected a few PyAutoGUI examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DFO-Ocean-Navigator / Ocean-Data-Map-Project / tests / frontend_tests / test_temperature.py View on Github external
def find_temperature_bar():
    """

    Function to locate the temperature bar on
    the ocean navigator public page. 
    
    """
    result = None
    time.sleep(2)
    screenWidth, screenHeight = gui.size()
    # Go to the navigator web page
    #navigator_webpage()
    # Locate temperature color bar on public page 
    image_loc = gui.locateCenterOnScreen(
        paths['test_temperature'], confidence=0.7, grayscale=True)

    if image_loc is None:
        gui.alert(text='Temperature bar not found!', title='Temperature bar', button='OK')
        result = 'Test Failed'
    else:
        gui.click(button='right', x=image_loc.x, y=image_loc.y)
        gui.alert(text='Temperature bar check complete!', title='Temperature bar', button='Close', timeout=box_timeout)
        result = 'Test Completed'
    return result, get_time()
github lukegarbutt / RunescapeBots / Original GE Mercher (old) / GEmercherv2.py View on Github external
item_to_buy.set_sold_at(sell_price)
	time.sleep(1)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/grandexchangetab.png'))
	time.sleep(1)
	print(string_of_item,'bought at', item_to_buy.bought_at, 'sold at', item_to_buy.sold_at)
	#adding in an undercut/overcut feature
	if item_to_buy.bought_at - item_to_buy.sold_at > 5:
		item_to_buy.set_bought_at(item_to_buy.bought_at - 1)
		item_to_buy.set_sold_at(item_to_buy.sold_at + 1)
	print(string_of_item,'values used are now bought at', item_to_buy.bought_at, 'sold at', item_to_buy.sold_at)
	#time to turn a profit
	pyautogui.click(buy_bag_loc[0], buy_bag_loc[1])
	time.sleep(2)
	pyautogui.typewrite(string_of_item, interval=random.random()/4)
	time.sleep(2)
	pyautogui.click(pyautogui.locateCenterOnScreen(item_to_buy.image_path))
	time.sleep(1)
	pyautogui.click(727, 524) #location of quantity box hard coded
	time.sleep(1)
	#finding a number to buy that fits our cash stack. This could be done better with keeping track of our cash stack and spending it accordingly buying some cheap and expensive items at the same time
	item_to_buy.set_number_to_buy(int(min(item_to_buy.available_to_buy, (amount_of_money/item_to_buy.sold_at)/len(list_of_locations_of_offer_boxes))))
	amount_of_money -= item_to_buy.number_to_buy*item_to_buy.sold_at
	pyautogui.typewrite(str(item_to_buy.number_to_buy), interval=random.random()/4)
	#pyautogui.typewrite(str(item_to_buy.limit), interval=0.25)   the way that worked@@@@@@@@@@@@
	time.sleep(1)
	pyautogui.press('enter')
	time.sleep(3)
	pyautogui.click(987, 524) #location of price box hard coded
	time.sleep(1)
	pyautogui.typewrite(str(item_to_buy.sold_at), interval=random.random()/4)
	time.sleep(1)
	pyautogui.press('enter')
github lukegarbutt / RunescapeBots / Original GE Mercher (old) / GEmercherv2.py View on Github external
time.sleep(1)
	increase_offer_loc = pyautogui.locateCenterOnScreen('images/+5percbutton.png')
	for i in range(random.randint(35,45)):
		pyautogui.click(increase_offer_loc)
		time.sleep(random.random()/30)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/+1button.png'))
	time.sleep(0.2)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
	time.sleep(5)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(item_completed.box_loc)))
	time.sleep(3)
	pyautogui.click(1091, 638) #loc of collect offer button 2 hard coded in 
	time.sleep(0.3)
	pyautogui.click(1034, 636) #loc of collect offer button 1 hard coded in 
	time.sleep(1)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/salehistorytab.png'))
	time.sleep(2)
	#add check here to make sure the item was actually bought using pytesser probs
	buy_price = tesser_image(screengrab_as_numpy_array((1179, 427, 1306, 455))) #location of price hard coded in
	print(item_completed.bought_at)
	item_completed.set_bought_at(buy_price)
	print(item_completed.bought_at)
	time.sleep(1)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/grandexchangetab.png'))
	time.sleep(1)
	pyautogui.click(pyautogui.center(pyautogui.locateOnScreen('images/sellbag.png', region=(item_completed.box_loc))))
	time.sleep(1)
	pyautogui.click(1159, 431) #location of item in inv
	time.sleep(1)
	pyautogui.click(987, 524) #location of price box hard coded
	time.sleep(1)
	pyautogui.typewrite(str(item_completed.bought_at), interval=random.random()/4)
github lukegarbutt / RunescapeBots / Original GE Mercher (old) / GEmercherv2.py View on Github external
pyautogui.click(1034, 636) #loc of collect offer button 1 hard coded in 
	time.sleep(1)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/salehistorytab.png'))
	time.sleep(2)
	#add check here to make sure the item was actually bought using pytesser probs
	buy_price = tesser_image(screengrab_as_numpy_array((1179, 427, 1306, 455))) #location of price hard coded in
	print(buy_price)
	item_to_buy.set_bought_at(buy_price)
	time.sleep(1)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/grandexchangetab.png'))
	time.sleep(2)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/sellbag.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
	time.sleep(2)
	pyautogui.click(1159, 431)#clicking item in inv hard coded
	time.sleep(1)
	decrease_offer_loc = pyautogui.locateCenterOnScreen('images/-5percbutton.png')
	for i in range(random.randint(35,45)):
		pyautogui.click(decrease_offer_loc)
		time.sleep(random.random()/30)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
	#time.sleep(5)
	#pyautogui.click(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
	#print(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
	time.sleep(5)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
	time.sleep(3)
	pyautogui.click(1091, 638) #loc of collect offer button 2 hard coded in 
	time.sleep(0.3)
	pyautogui.click(1034, 636) #loc of collect offer button 1 hard coded in 
	time.sleep(1)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/salehistorytab.png'))
	time.sleep(2)
github theriley106 / Nightchord / main.py View on Github external
def clickFile():
	pyautogui.click(pyautogui.locateCenterOnScreen('src/images/audacity_fileButton.png'))
github eficode / robotframework-imagehorizonlibrary / src / ImageHorizonLibrary / recognition / _recognize_images.py View on Github external
def try_locate(ref_image):
            location = None
            with self._suppress_keyword_on_failure():
                try:
                    location = ag.locateCenterOnScreen(ref_image.encode('utf-8'))
                except ImageNotFoundException:
                    pass
            return location
github gil9red / SimplePyScripts / pyautogui__keyboard__examples / locate_center_on_screen.py View on Github external
def locate_center_on_screen(needle_image, screenshot_image=None):
    if screenshot_image:
        rect = pyautogui.locate(needle_image, screenshot_image)
        if rect:
            return pyautogui.center(rect)

    return pyautogui.locateCenterOnScreen(needle_image)
github lukegarbutt / RunescapeBots / Original GE Mercher (old) / GEmercherv2.py View on Github external
buy_bag_loc = pyautogui.locateCenterOnScreen('images/buybag.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3]))
	pyautogui.click(buy_bag_loc[0], buy_bag_loc[1])
	time.sleep(2)
	#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	item_index = 0
	#item_index = random.randint(0,len(list_of_items_to_buy)-1)
	#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	#print(item_index, 'item index')
	item_to_buy = list_of_items_to_buy[item_index]
	list_of_items_to_buy.pop(item_index)
	string_of_item = str(item_to_buy.item)
	pyautogui.typewrite(string_of_item, interval=random.random()/4)
	time.sleep(2)
	pyautogui.click(pyautogui.locateCenterOnScreen(item_to_buy.image_path))
	time.sleep(2)
	increase_offer_loc = pyautogui.locateCenterOnScreen('images/+5percbutton.png')
	for i in range(random.randint(35,45)):
		pyautogui.click(increase_offer_loc)
		time.sleep(random.random()/30)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/+1button.png'))
	time.sleep(0.2)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
	#time.sleep(5)
	#pyautogui.click(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
	#print(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
	time.sleep(5)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/completedoffer.png', region=(list_of_locations_of_offer_boxes[offer_box_index][0],list_of_locations_of_offer_boxes[offer_box_index][1], list_of_locations_of_offer_boxes[offer_box_index][2], list_of_locations_of_offer_boxes[offer_box_index][3])))
	time.sleep(3)
	pyautogui.click(1091, 638) #loc of collect offer button 2 hard coded in 
	time.sleep(0.3)
	pyautogui.click(1034, 636) #loc of collect offer button 1 hard coded in 
	time.sleep(1)