def attempt_to_click_on(picture, region, is_game=False, is_riot_client=False, click=True, conf=0.95, delay=True): if not globals.go_flag: return False picture = os.path.join(globals.picture_path, picture) try: if is_game: rect = utilities.get_game_coords() elif is_riot_client: rect = utilities.get_riot_client_coords() else: rect = utilities.get_client_coords() if region is not None: start_x = rect[0] + region[0] start_y = rect[1] + region[1] width = region[2] - region[0] height = region[3] - region[1] rect = (start_x, start_y, width, height) coordinates = pyautogui.locateCenterOnScreen(picture, region=rect, confidence=conf) if coordinates is not None: if click: pyautogui.click(coordinates[0], coordinates[1]) globals.time_since_last_click = timer() if delay: time.sleep(1) return True except Exception: return False
def complete_game(): utilities.set_status('Waiting for game to start...') # Wait until recall is visible, then we know we're in game while not attempt_to_click_on( pictures.recall, None, is_game=True, click=False): pause_if_needed() # Lock the screen once we're in game lock_screen() # Click mid utilities.set_status('Running it down mid...') game_flag = 1 while game_flag: pause_if_needed() # If we're out of game if not utilities.is_league_in_game(): game_flag = 0 continue # Get the location of league window try: rect = utilities.get_game_coords() except Exception: continue x = rect[0] + 1260 y = rect[1] + 592 # Right click down mid every 1 second try: win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEDOWN, x, y, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEUP, x, y, 0, 0) time.sleep(1) except Exception: continue # Once the game is finished increment_games() # Check to see if the bot is finished all games if globals.number_of_games_finished == globals.number_of_games_to_play: stop_bot() return # Skip honor globals.time_since_last_click = timer() while not attempt_to_click_on(pictures.skip_honor, None): if did_timeout(30): client_stuck() return time.sleep(1) # Requeue for another game utilities.set_status("Currently queueing for a game...")
def complete_game(): utilities.set_status('Waiting for game to start...') # Wait until recall button is visible, then we know we're in game while not attempt_to_click_on( pictures.recall, None, is_game=True, click=False): pause_if_needed() # Click mid utilities.set_status('Running it down mid...') while True: pause_if_needed() # If we're out of game if not utilities.is_league_in_game(): break # If the camera isn't locked, lock it if attempt_to_click_on(pictures.lock_camera, None, is_game=True, click=False): lock_screen() # Get the location of league window try: rect = utilities.get_game_coords() except Exception: continue x = rect[0] + 1260 y = rect[1] + 592 # Right click down mid every 3 seconds try: win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0) time.sleep(3) except Exception: continue # Once the game is finished increment_games() # Skip honor globals.time_since_last_click = timer() while not attempt_to_click_on(pictures.skip_honor, None): if did_timeout(30): client_stuck() return time.sleep(1) # Requeue for another game utilities.set_status("Queueing for a game...")
def lock_screen(): try: rect = utilities.get_game_coords() x, y = regions.game_lockscreen_coords x = rect[0] + x y = rect[1] + y win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0) time.sleep(0.1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0) except Exception: pass