def click2(self): pyautogui.FAILSAFE = False while True: try: print("Kurulumlar tamamdır") while True: try: if imagesearch(image="kutu1.PNG")[0] != -1: try: leftClick(imagesearch(image="kutu1.PNG")) sleep(2) print("Kutu toplandı") except: print("Sorun Oluştu 502") leftClick(608, 396) continue sleep(0.5) else: leftClick(randint(1075, 1334), randint(519, 673)) sleep(2) except: leftClick(608, 396) continue except: print("Sorun Oluştu 400") leftClick(608, 396) continue finally: leftClick(608, 396) system("python3 darkorbit_bot.py") continue
def search_image(): pos = imagesearch("./github.png") pos1 = imagesearch("./github1.png") if pos[0] & pos1[0] != -1: start_countdown() else: root.after(100, search_image)
def checkGameCancelled(): accepted = imagesearch(acceptedButtonImg) play = imagesearch(playButtonImg) if accepted[0] == -1 and not play[0] == -1: return True else: return False
def checkChampSelect(): flash = imagesearch(championSelectionImg_flash) emote = imagesearch(championSelectionImg_emote) if emote[0] != -1 or flash[0] != -1: return True else: return False
def checkDodge(): accepted = imagesearch(acceptedButtonImg) play = imagesearch(playButtonImg) if accepted[0] == -1 and play[0] != -1: return True else: return False
def checkChampionSelection(): flash = imagesearch(championSelectionImg_flash) emote = imagesearch(championSelectionImg_emote) if not emote[0] == -1 or not flash[0] == -1: return True else: return False
def getCarouselItem(): bowItem = imagesearch("./assets/carousel/bow.png") if bowItem[0] != -1: print("bowFound", bowItem[0], bowItem[1]) #pyautogui.moveTo(bowItem[0], bowItem[1]) pyautogui.mouseDown(x=bowItem[0], y=bowItem[1], button='right') pyautogui.mouseUp(x=bowItem[0], y=bowItem[1], button='right') pyautogui.mouseDown(x=bowItem[0], y=bowItem[1], button='right') pyautogui.mouseUp(x=bowItem[0], y=bowItem[1], button='right') else: print("bow not found") broadswordItem = imagesearch("./assets/carousel/broadsword.png") if broadswordItem[0] != -1: print("broadswordFound", broadswordItem[0], broadswordItem[1]) pyautogui.mouseDown(x=broadswordItem[0], y=broadswordItem[1], button='right') pyautogui.mouseUp(x=broadswordItem[0], y=broadswordItem[1], button='right') pyautogui.mouseDown(x=broadswordItem[0], y=broadswordItem[1], button='right') pyautogui.mouseUp(x=broadswordItem[0], y=broadswordItem[1], button='right') else: print("broadsword not found") tearItem = imagesearch("./assets/carousel/tear.png") if tearItem[0] != -1: print("tearFound", tearItem[0], tearItem[1]) pyautogui.mouseDown(x=tearItem[0], y=tearItem[1], button='right') pyautogui.mouseUp(x=tearItem[0], y=tearItem[1], button='right') pyautogui.mouseDown(x=tearItem[0], y=tearItem[1], button='right') pyautogui.mouseUp(x=tearItem[0], y=tearItem[1], button='right') else: print("tear not found") beltItem = imagesearch("./assets/carousel/belt.png") if beltItem[0] != -1: print("beltFound", beltItem[0], beltItem[1]) pyautogui.mouseDown(x=beltItem[0], y=beltItem[1], button='right') pyautogui.mouseUp(x=beltItem[0], y=beltItem[1], button='right') pyautogui.mouseDown(x=beltItem[0], y=beltItem[1], button='right') pyautogui.mouseUp(x=beltItem[0], y=beltItem[1], button='right') else: print("belt not found")
def selectchamp(champ): pos = imagesearch(champsearchbox) pyautogui.click(pos[0] + 45, pos[1] + 5) pyautogui.write(champ) time.sleep(1) pos2 = imagesearch(champpicture) ahk.click(pos2[0] + 2, pos2[1] + 2) print("Champion Selected") pos3 = imagesearch(hazirbuton) time.sleep(1) pyautogui.click(pos3[0], pos3[1])
def do_get_water_can(self): pos1 = imagesearch(self.main_path + "\\task_images\\get_water_can\\can1.jpg") pos2 = imagesearch(self.main_path + "\\task_images\\get_water_can\\can2.jpg") if pos1[0] != -1: pyautogui.moveTo((pos1[0] + 7, pos1[1] + 7)) else: pyautogui.moveTo((pos2[0] + 7, pos2[1] + 7)) pyautogui.mouseDown() pyautogui.mouseUp()
def imagesearch_loop(image, timesample, precision=0.8): pos = imagesearch(image, precision) print(image[-13:] + " not found, waiting...") if image != "./assets/inGameIcons/rounds/round_1/1_1_round.png": while pos[0] == -1: time.sleep(timesample) pos = imagesearch(image, precision) else: while pos[0] == -1: time.sleep(timesample) pyautogui.moveTo(978, 715) pyautogui.click() pos = imagesearch(image, precision) print(image[-13:] + " found.") print("-------------------------") return pos
def do_fix_weather_node_switch(self): pos = imagesearch(self.main_path + "\\task_images\\fix_weather_node_switch\\wrong.jpg") pyautogui.moveTo(pos[0] + 40, pos[1] + 30) pyautogui.click()
def see(image): position = imgsearch.imagesearch(path + image + '.png') if position[0] != -1: if debug: print(f'SEE: {image} {str(position)}') return True else: return False
def imagesearch_example(): for file in os.listdir(os.path.curdir): if file.lower().endswith('.png'): pos = imagesearch(file) if type(pos) is tuple: print("position : ", pos[0], pos[1]) else: print("image not found")
def acceptgame(): while True: pos = imagesearch(kabuletbuton) if pos[0] != -1: print("Match Found") pyautogui.click(pos[0] + 45, pos[1] + 5) print("Match Accepted") break
def checkQueuePop(): while True: pos = imagesearch(acceptButtonImg) if pos[0] != -1: pyautogui.click(pos[0], pos[1]) # send notification to phone print("Game accepted") break time.sleep(TIMELAPSE)
def FindImage(name): if not name.endswith(".png"): name += ".png" file = ImageFolder + name try: location = imagesearch(file) return location if location[0] != -1 else False except: return False
def checkGameAvailableLoop(): while True: pos = imagesearch(acceptButtonImg, 0.8) if not pos[0] == -1: pyautogui.click(pos[0], pos[1]) print("Game accepted!") break time.sleep(TIMELAPSE)
def do_insert_keys(self): key_pos = imagesearch(self.main_path + "\\task_images\\insert_keys\\0.jpg") hole_pos = imagesearch(self.main_path + "\\task_images\\insert_keys\\1.jpg") pyautogui.moveTo(key_pos[0] + 3, key_pos[1] + 10) pyautogui.mouseDown() pyautogui.moveTo(hole_pos[0] + 30, hole_pos[1] + 30) pyautogui.mouseUp() pyautogui.moveTo(hole_pos[0] + 80, hole_pos[1]) pyautogui.mouseDown() pyautogui.moveTo(hole_pos[0] + 150, hole_pos[1] + 150) pyautogui.mouseUp()
def checkforgamebreak(): while True: pos = imagesearch(profilebuton) if pos[0] != -1: print("Match Dodged") print("Waiting ...") acceptuntilfound() selectchamp() ingamecheck = gamestartedcheck() if ingamecheck == True: break
def search_click(image_path, wait_time = 0.5): time.sleep(wait_time) pos = imagesearch(image_path) if pos[0] != -1: txt_var = 'Image Clicked - ' + get_img_name(image_path) log("INFO", "wrapper.search_click", txt_var) click_image(image_path, pos, "left", 0, offset=0) else: txt_var = 'Cant find Image to Click - ' + get_img_name(image_path) log("WARNING", "wrapper.search_click", txt_var) return False
def click_button(img, xMod=0, yMod=0): # attempts to locate the image and then clicks the button at the given # position. returns true for clicking the image, and false if the image # can't be found. Modifiers allow to click an image precisely x, y = imagesearch(img) if -1 not in (x, y): kbm.click(x + xMod, y + yMod) return True else: return False
def checkforlevelup(): global killthreads while True: if killthreads == True: print("levelup thread killed") break pos = imagesearch(levelup) if pos != -1: ahk.click(pos[0] + 5, pos[1] + 5) ahk.click(pos[0] + 5, pos[1] + 5) print("Level Up") time.sleep(20)
def search_click_offset(image_path, offsetX, offsetY, wait_time=0.5): time.sleep(wait_time) pos = imagesearch(image_path) print(pos) if pos[0] != -1: txt_var = 'Image Offset Clicked - ' + get_img_name(image_path) log("INFO", "wrapper.search_click_offset", txt_var) click_image_offset(image_path, pos, offsetX, offsetY, "left", 0, offset=0) else: txt_var = 'Image Not Found - ' + get_img_name(image_path) log("WARNING", "wrapper.search_click_offset", txt_var) return False
def claim_quests(self): """ Description: Check quests and check off any quests that can be completed. Input: none Output: (Boolean) true or false """ outcome = False #if self.quest_list["status"]["daily_quests"] != True: if event.find_image(image.quest_window_title.value) == False: event.search_click(image.quest_icon.value) time.sleep(1) pyautogui.moveTo(1017, 419) pyautogui.dragTo(1017, 438, 0.5, button='left') while imagesearch(image.quest_claim_x5.value, 0.9)[0] != -1: event.search_click(image.quest_claim_x5.value) if imagesearch(image.quest_claim_x15.value, 0.9)[0] != -1: event.search_click(image.quest_claim_x15.value) outcome = True event.click_button_validate(image.close_quest.value) print('All quest claimed:', outcome) return outcome
def busca_por_imagem(name_img): pos = imagesearch(f"./data/{name_img}.JPG") img = cv2.imread(f"./data/{name_img}.JPG") size = img.shape print(size) if pos[0] != -1: ahk = AHK(executable_path='./ahk_folder/AutoHotkeyA32.exe') ahk.mouse_move(x=pos[0] + (size[1] / 2), y=pos[1] + (size[0] / 2)) ahk.click(direction='down') time.sleep(0.008) ahk.click(direction='up') else: busca_por_imagem(name_img)
def search_loop(checks, wait_time): global checking global state while checking: precision = .8 if curr_system == 'Darwin' else .9 for check in checks: if imagesearch(check[0], precision)[0] != -1: state[check[1]] = check[2] else: if check[3] != -1: state[check[1]] = check[3] time.sleep(wait_time)
def get_daily_gem_ads(self): #Input: None #Output: Success of Operation print("Daily Gem Ads Status:", self.rewards_list["status"]["daily_free_gems"]) if self.rewards_list["status"]["daily_free_gems"] == False: event.search_click(image.store_icon.value) time.sleep(1) while imagesearch(image.ad_ruby_invalid.value, 0.9)[0] == -1: game.watchAds(image.ad_ruby.value, image.store_rubies.value) time.sleep(2) self.rewards_list["status"]["daily_free_gems"] = True event.click_next_screen_validate(image.ads_close.value, image.battle_button.value) return self.rewards_list
def start(): win = ahk.find_window(title=b'League of Legends') win.activate() conf = getconfig() searchgame() acceptuntilfound() selectchamp(conf[1]) checkforgamebreak() while True: pos = imagesearch(levelup) if pos != -1: time.sleep(30) playgame(conf[2], conf[3]) break
def searchgame(): pos = imagesearch(oynabuton) if pos[0] != -1: pyautogui.click(pos[0] + 45, pos[1] + 5) time.sleep(2) pyautogui.click(pos[0] + 100, pos[1] + 70) time.sleep(2) pyautogui.click(pos[0] + 500, pos[1] + 655) time.sleep(4) pyautogui.click(pos[0] + 500, pos[1] + 655) print("Searching for match ...") acceptgame() else: print("Please go back to home page and try again")
def checkGameAvailableLoop(): while True: pos = imagesearch(acceptButtonImg) if not pos[0] == -1: if pos[0] >= 1920: posX = int(pos[0]) - 1920 pyautogui.click(posX, pos[1]) else: pyautogui.click(pos[0], pos[1]) # print("Game accepted!") break time.sleep(TIMELAPSE)