How to use the pyautogui.center 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 sneakypete81 / updatescanner / test / functional / regions / element.py View on Github external
def _locate_centre(self):
        if self._location_matches_expected():
            return pyautogui.center(self.expected_region)

        # Element is not where we expected it to be, so search the region
        result = self._locate_in_screen_region()

        self._issue_warnings(result)
        return pyautogui.center(result)
github sneakypete81 / updatescanner / test / functional / regions / element.py View on Github external
def _locate_centre(self):
        if self._location_matches_expected():
            return pyautogui.center(self.expected_region)

        # Element is not where we expected it to be, so search the region
        result = self._locate_in_screen_region()

        self._issue_warnings(result)
        return pyautogui.center(result)
github asweigart / sushigoroundbot / sushigoroundbot.py View on Github external
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.info('Game over. Quitting.')
        sys.exit()
github lukegarbutt / RunescapeBots / Original GE Mercher (old) / GEmercherv2.py View on Github external
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)
	time.sleep(1)
	pyautogui.press('enter')
	time.sleep(3)
	pyautogui.click(pyautogui.center(pyautogui.locateOnScreen('images/allbutton.png')))
	time.sleep(3)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
	time.sleep(1)
github gil9red / 2048_bot / utils.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 gil9red / SimplePyScripts / pyautogui__keyboard__examples / win_calc_clicker / main__locateAllOnScreen.py View on Github external
# pip install pyautogui
import pyautogui

expression = '1234 * 222 + 3214 = '

for x in expression:
    if x not in BUTTONS:
        print('Not found: "{}"'.format(x))
        continue

    if x in cache_pos_button:
        pos_list = cache_pos_button[x]
    else:
        file_name = BUTTONS[x]
        pos_list = [pyautogui.center(pos) for pos in pyautogui.locateAllOnScreen(BUTTONS[x])]
        if not pos_list:
            continue

        cache_pos_button[x] = pos_list

    print(x, pos_list)
    for pos in pos_list:
        pyautogui.click(pos)
github lukegarbutt / RunescapeBots / Original GE Mercher (old) / GEmercherv2.py View on Github external
def collect_money_or_items(item_completed):
	time.sleep(1)
	pyautogui.click(pyautogui.center(item_completed.box_loc))
	time.sleep(1)
	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)
github lukegarbutt / RunescapeBots / Original GE Mercher (old) / GEmercherv2.py View on Github external
def sell_items(item_completed):
	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)
	time.sleep(1)
	pyautogui.press('enter')
	time.sleep(3)
	pyautogui.click(pyautogui.locateCenterOnScreen('images/confirmofferbutton.png'))
	time.sleep(1)
github ugraveknight / Healslut-Master / OWKillfeedMonitor.py View on Github external
def Main(im,Files,Sub,Dom,Cords,c_killfeed,KFPath,BorderPixels,Debug=False):
	try:
		newtime = time() if Debug==True else 0
		for file in Files:
			newtime = LogTime(file,Files,newtime) if Debug==True else 0
			for userloc in locateAll(file, im, confidence=0.9, region=Cords):
				x, y = center(userloc)
				if not 'Assist' in file:
					TeamColor = GenTeamColor(im, x-BorderPixels[1], y)
					red, green, blue = im.getpixel((int(x)-BorderPixels[2], int(y)))
					if red > 250 and green > 245 and      blue > 240 or \
					   red > 250 and green < 20  and 30 < blue < 50:
						name = file.replace(KFPath,'').replace('.png','')
						TrackDeath(name,TeamColor,Sub,Dom,c_killfeed)
				else:
					TeamColor = GenTeamColor(im, x-BorderPixels[0], y)	#BorderPixels = 15 on 2560
					name = file.replace(KFPath,'').replace('.png','')
					if Sub in name and TeamColor == 'Blue':
						TreatSub('Assist',name,c_killfeed)
	except KeyboardInterrupt:
		pass