def Q_reward(): #13 업적 보상받기 mouse_move(20, 200, 70, 240) sleep_0() pyautogui.click(button='left') sleep_2() sleep_2() pos = imagesearch("Q_reward1.png") while pos[0] != -1: pos = imagesearch("Q_reward1.png") search_click("Q_reward1.png") sleep_2() search_click("Q_reward2.png") sleep_2() search_click("Q_reward3.png") sleep_1() pos = imagesearch("Q_reward1.png") while pos[0] != -1: pos = imagesearch("Q_reward1.png") search_click("Q_reward1.png") sleep_2() search_click("Q_reward2.png") sleep_2() search_click("Q_reward4.png") sleep_1()
def tinyfarm() : search_click("0_tinyfarm.png") pyautogui.click(button='left') pyautogui.click(button='left') pos = imagesearch("1_login4.png") while pos[1] == -1: pos = imagesearch("1_login4.png") search_click("0_tinyfarm1.png") search_click("0_tinyfarm2.png") search_click("0_tinyfarm3.png") sleep_2() search_click("0_tinyfarm3.png") search_click("0_tinyfarm3.png") search_click("0_tinyfarm3.png") search_click('1_login4.png') sleep_0() search_click("0_tinyfarm3.png") search_click('1_login4.png') #logout time.sleep(random.uniform(2.5001, 3.9987)) #id 입력 pos = imagesearch("1_login2.png") while pos[1] == -1: pos = imagesearch("1_login2.png") search_click('1_login4.png') sleep_2() search_click('1_login1.png') sleep_2() search_click('1_login1_1.png')
def toah(): conditional = -1 loop = 1 fails = 0 print("Testing Toa.") while (loop == 1): while (conditional == -1): pos = imagesearch("./images/victory-paint.png") pos2 = imagesearch("./images/no.png") if (pos[0] != -1): #If Victory img is found conditional = 1 print(conditional) elif (pos2[0] != -1): #If Fail is found. conditional = 2 #If run is successful: if (conditional == 1): toa() elif (conditional == 2): logging.info("Script has ended.") sys.ext()
def Q_village(): #10마을 출석, 애정환원 pos = imagesearch("Q_village1.png") while pos[1] == -1: mouse_move(20, 270, 70, 310) sleep_0() pyautogui.click(button='left') sleep_2() pos = imagesearch("Q_village1.png") search_click("Q_village1.png") sleep_1() search_click("Q_village2.png") sleep_1() search_click("Q_village2_1.png") sleep_2() search_click("Q_village3.png") sleep_1() pos = imagesearch("Q_village3_1.png") while pos[0] != -1: search_click("Q_village3_1.png") sleep_1() mouse_move(240, 425, 300, 440) sleep_0() pyautogui.click(button='left') sleep_2() search_click("Q_village3_2.png") sleep_1() search_click("Q_village3_3.png") sleep_1() pos = imagesearch("Q_village3_1.png") sleep_1() # pos = imagesearch("Q_hunt_2_2.png") # while pos[0] == -1 : search_click("Q_village4.png") sleep_1()
def findBox(): #25x25 #block starts at 8,8 topLeftCoord = imagesearch("findUpperleft.png") firstSquare = [0, 0] firstSquare[0] = topLeftCoord[0] + 8 firstSquare[1] = topLeftCoord[1] + 8 #24x24 #block ends at 15,15 botRightCoords = imagesearch("findBottomRight.png") lastSquare = [0, 0] lastSquare[0] = botRightCoords[0] + 15 lastSquare[1] = botRightCoords[1] + 15 #Returns [[TopLeftCoord],[xwidth,ywidth]] retval = calcBox(firstSquare, lastSquare) global numSquaresX numSquaresX = retval[0] / 16 print("numSquaresX", numSquaresX) global numSquaresY numSquaresY = retval[1] / 16 print("numSquaresY", numSquaresY) return firstSquare
def Q_luckybag() : #8럭키백 pos = imagesearch("Q_luckbag1.png") while pos[1] == -1: mouse_move(800, 70, 840, 100) sleep_0() pyautogui.click(button='left') sleep_1() pos = imagesearch("Q_luckbag1.png") search_click("Q_luckbag1.png") pos = imagesearch("Q_luckbag4.png") while pos[0] == -1: pos = imagesearch("Q_luckbag4.png") search_click("Q_luckbag2.png") search_click("Q_luckbag3.png") sleep_2() search_click("Q_luckbag4.png") sleep_2() search_click("Q_luckbag5.png") sleep_2() search_click("Q_luckbag4.png") sleep_2() search_click("Q_luckbag5.png") sleep_2() search_click("Q_luckbag4.png") sleep_2() search_click("Q_luckbag5.png") sleep_2() search_click("Q_luckbag5.png")
def auto(self): pos = imagesearch("images/auto.png") if pos[0] != -1: print("AUTO FOUND") pyautogui.click(pos[0], pos[1]) time.sleep(1) pos = imagesearch("images/autoconfirm.png") if pos[0] != -1: pyautogui.click(pos[0], pos[1]) time.sleep(1)
def login(id, pw) : #id 입력 pos = imagesearch("1_login2.png") while pos[1] == -1: pos = imagesearch("1_login2.png") search_click('1_login4.png') sleep_2() search_click('1_login1.png') sleep_1() search_click('1_login1_1.png') sleep_2() search_click('1_login1.png') pyautogui.press('end') sleep_1() #backspace 7번 pyautogui.press('backspace') sleep_0() pyautogui.press('backspace') sleep_0() pyautogui.press('backspace') sleep_0() pyautogui.press('backspace') sleep_0() pyautogui.press('backspace') sleep_0() pyautogui.press('backspace') sleep_0() pyautogui.press('backspace') sleep_0() pyautogui.press('backspace') sleep_0() # pyautogui.press('backspace') pyautogui.typewrite(id, random.uniform(0.30001, 0.69999)) #한글 입력은 안 됨 sleep_1() pyautogui.press('tab') #pw 입력 sleep_1() pyautogui.typewrite(pw, random.uniform(0.30001, 0.69999)) # pyautogui.press('tab') # pyautogui.press('Enter') sleep_2() sleep_0() search_click('1_login2.png') time.sleep(random.uniform(2.5001, 4.9987)) search_click("0_tinyfarm3.png") sleep_0() pos = imagesearch("1_login3.png") if pos[0] != -1: search_click("1_login3.png") time.sleep(random.uniform(1.55001, 2.79987)) else : print("something wrong~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") restart()
def play(): pos2 = imagesearch("dead.png") while pos2[0] == -1: pos = imagesearch("onesquare.png") if pos[0] != -1: print("position : ", pos[0], pos[1]) pyautogui.moveTo(pos[0], pos[1]) pyautogui.click(pos[0] + 3, pos[1] + 3, 2, 0, 'left') pos2 = imagesearch("dead.png") else: print("image not found")
def first() : #로그인시 클릭해야할것들 1 pos = imagesearch("1_login4.png") while pos[0] != -1: pos = imagesearch("1_login4.png") sleep_2() print("loopout") presence = imagesearch("3_first1.png") if (presence[0] != -1) : search_click("3_first1.png") sleep_2() search_click("3_first2.png") sleep_2() search_click("3_first3.png") sleep_2() search_click("3_first4.png") sleep_2() run_bell() print(" 6. 모험 확인하기") Q_hunt_1() search_click_range("5_food3.png") print(" 7. 교배소") Q_animal() print(" 8. 럭키백") Q_luckybag() print(" 9. 마을출석, 애정환원") Q_village() search_click_range("5_food3.png") run() mouse_move(800, 350, 840, 420) mouse_scroll(-1) time.sleep(random.uniform(0.60001, 1.09999)) mouse_scroll(-1) time.sleep(random.uniform(0.60001, 1.09999)) # run() #+확인버튼 #프렌드 막히는 부분 수정하기 print(" 10. 친구 애정주기") Q_friend() search_click_range("5_food3.png") #나갔다 오는게 나을듯.. else : search_click("3_first5.png") sleep_2() run_bell() print(" 6-1. 모험 확인하기") Q_hunt_1()
def clickB10(): button = imagesearch('./images/b10.png') end = imagesearch('./images/shake_icon.png') result = imagesearcharea('./images/start_battle_screen2.png', button[0], button[1], end[0], end[1]) final = (button[0] + result[0], button[1] + result[1]) click_image('./images/start_battle_screen2.png', final, "left", 0.2, offset=5) time.sleep(2)
def Q_farm(): #12 밭 수거 search_click("Q_farm1.png") pos = imagesearch("Q_farm2.png") while pos[1] == -1: pos = imagesearch("Q_reward1.png") search_click("Q_farm2.png") search_click("Q_farm3.png") search_click("Q_farm4.png") search_click("Q_farm5.png") search_click("Q_farm6.png")
def suche_pic_two_prec(self, img, img2, img3, duration): image = '//Users//fusselmania//Desktop//bot//' + img + '.png' image2 = '//Users//fusselmania//Desktop//bot//' + img2 + '.png' image3 = '//Users//fusselmania//Desktop//bot//' + img3 + '.png' for i in range(0, duration): pos = imagesearch(image, precision=0.95) pos2 = imagesearch(image2, precision=0.99) pos3 = imagesearch(image3, precision=0.95) if pos[0] != -1: return 1 elif pos2[0] != -1: return 2 elif pos3[0] != -1: return 3 cv2.waitKey(1)
def get_start_pos_board(): """ Return the left-top position of the board """ pos = imagesearch("Images/init_board.jpg") print(pos[0], pos[1] + get_dimension_board()[1]) return pos[0], pos[1] + get_dimension_board()[1]
def go_and_long_click_polite(image): pos = imagesearch(image, precision) if pos[0] == -1: return 0 moveTo(pos[0], pos[1]) long_click_here() return 1
def move_and_click(image, precision=0.8, display_unavailable=True, sleep_before=0, sleep_after=0): """ Scans for an image, moves to it, and clicks on it if available. Returns True if image exists, otherwise returns False. """ sleep(sleep_before) image_available = False pos = imagesearch(image, precision=precision) if pos[0] != -1: # print(f"position of {image}: {pos[0]} {pos[1]}") # left click image at its found position after tasking 0.2s to reach the image sleep(0.5) click_image(image, pos, "left", 0.2, 1) sleep(sleep_after) image_available = True else: image_available = False if display_unavailable: print(f"{image} not available.") sleep(sleep_after) return image_available
def close(self): pos = imagesearch("images/close.png") if pos[0] != -1: print("CLOSE FOUND") pyautogui.click(pos[0], pos[1]) time.sleep(1) self.start()
def fight_small(self): pos = imagesearch("images/fightsmall.png") if pos[0] != -1: print("FIGHT SMALL FOUND") pyautogui.click(pos[0], pos[1]) time.sleep(1) self.fight_large()
def search_loop(image_directory): search_bool = 0 while (search_bool != 1): search_pos = imagesearch(image_directory) if (search_pos[0] != -1): search(image_directory) search_bool = 1
def checkSlot(image_directory, slot_num): slot_pos = imagesearch(image_directory) if (slot_pos[0] != -1): print("Slot " + str(slot_num)) return slot_num else: return -1
def findImgAndClick(self,imageName, precision = 0.90): absolute_path = os.path.join(os.getcwd(), self.gv.imageFolderName, imageName) pos = imagesearch(absolute_path, precision) if pos[0] != -1: click_image(absolute_path, pos, "left", 0, False, offset=5) return True return False
def run() : #클릭하기 max_retries = 4 retries = 0 while True: if retries >= max_retries: sleep_2() break presence = imagesearch("5_food1.png") if (presence[1] == -1): retries += 1 search_click_range("5_food2.png") search_click_range("5_food3.png") search_click_range("5_food3_1.png") search_click_range("friend4.png") search_click_range("friend5.png") search_click_range("friend4.png") search_click_range("friend6.png") search_click_range("friend4.png") continue else : search_click_range("4_building2.png") search_click_range("4_building3.png") search_click_range("5_food1.png") search_click_range("5_food2.png") search_click_range("5_food3.png") search_click_range("friend1.png") search_click_range("friend2.png") search_click_range("friend3.png") search_click_range("2_logout4_building1.png") continue
def check_restore(self): pos = imagesearch("images/restore.png") if pos[0] != -1: print("RESTORE FOUND") pyautogui.click(pos[0], pos[1]) time.sleep(1) self.close()
def verificaCallSpirits(): global regionBuff callSpiritsPath = r'C:\Users\Neimar\PycharmProjects\ragAutomation\imagens\callSpirits.png' imgR = imagesearch(callSpiritsPath, 0.7) imgR = imagesearchareaRag(callSpiritsPath, regionBuff, precision=0.9) #se nao achou, entao tem q dar call if imgR is None: usaCallSpirits()
def quizSearch(image_directory): delay = random.randint(1, 2) button = imagesearch(image_directory, 0.7) if button[0] != -1: print("FOUND: " + image_directory) return button else: #print( image_directory + "not found.") return -1
def hasSPD(): start = imagesearch('./images/rune/set/swift_2.png') end = imagesearch('./images/ok.png') #print (start) #print (end) aoi = imagesearcharea('./images/rune/spd.png', start[0] - 220, start[1], end[0], end[1] - 75) if (aoi[0] != -1): #im = pyautogui.screenshot(region=(aoi[0],aoi[1],end[0],end[1])) #im.save("sublocation.png") #print(aoi) return True else: #print("SPD sub not found.") return False
def isRuneType(rune_type): if (rune_type == "swift"): pos = imagesearch('./images/rune/set/swift_2.png') elif (rune_type == "energy"): pos = imagesearch('./images/rune/set/energy.png') elif (rune_type == "blade"): pos = imagesearch('./images/rune/set/blade.png') elif (rune_type == "despair"): pos = imagesearch('./images/rune/set/despair.png') elif (rune_type == "fatal"): pos = imagesearch('./images/rune/set/fatal.png') else: print("Unknown Rune Type.") if (pos[0] != -1): return True else: return False
def dimensionalRiftBypass(): ok_pos = imagesearch('./images/ok.png') if (ok_pos != -1): search('./images/ok.png') search('./images/reverse.png') search('./images/battle_icon.png') time.sleep(10) search('./images/cairos_dungeon.png') time.sleep(2)
def verifyBattle(): img = imagesearch(getImageFolder() + 'battleFound.png', precision=0.8) if img is not None: print("battleFound!") sleep(1) img = imagesearch_numLoop(getImageFolder() + 'fight.png', 1, 5, precision=0.8) if img is not None: if 'fight' in Battle.command: battle(Battle.command)
def closeAds(): ad = 0 while (ad < 5): start_ad_pos = imagesearch('./images/start_ad_close.png') if (start_ad_pos[0] != -1): search('./images/start_ad_close.png') ad = ad + 1 else: ad = 10