def loop(hwnd): baseImg = "../images/blackground.jpg" # 储存的文件名 # 储存的文件名 rect = win32gui.GetWindowRect(hwnd) WindowCapture.window_capture(baseImg, hwnd) # 对整个屏幕截图,并保存截图为baseImg # 遍历所有图片 for filename in os.listdir(r"../images/images-fight"): # listdir的参数是文件夹的路径 imagePath = "../images/images-fight/" + filename res = matchImg(baseImg, imagePath, 0.9) if res is None: continue # if filename == "exp.png": # y = rect[1] - 120 # else: # continue # #y = rect[1] + res["result"][1] # x = rect[0] + res["result"][0] print(filename) if filename == "reward.png" or filename == "finded.png": x = rect[0] + 20 y = rect[1] + 560 else: x = rect[0] + res["result"][0] y = rect[1] + res["result"][1] move_x = random.randint(int(x) - 2, int(x) + 2) move_y = random.randint(int(y) - 2, int(y) + 2) click_it((move_x, move_y), hwnd) if filename == "3.png" or filename == "4.png" or filename == "5.png" or filename == "6.png" or filename == "1.png": break
def loop_2(hwnd, baseImgPath="../images/background2.jpg", imageDirPath="../images/shower/"): while True: time.sleep(1) print("洗澡线程正在执行......") baseImg = baseImgPath # 储存的文件名 rect = win32gui.GetWindowRect(hwnd) WindowCapture.window_capture(baseImg, hwnd) # 对整个屏幕截图,并保存截图为baseImg # 遍历所有图片 for filename in os.listdir(imageDirPath): # listdir的参数是文件夹的路径 imagePath = imageDirPath + filename res = matchImg(baseImg, imagePath, 0.7) if res is None: continue if filename == "reward.png": x = rect[0] + 20 y = rect[1] + 560 else: x = rect[0] + res["result"][0] y = rect[1] + res["result"][1] move_x = random.randint(int(x) - 2, int(x) + 2) move_y = random.randint(int(y) - 2, int(y) + 2) print(move_x, move_y) click_it((move_x, move_y), hwnd) # 判断是否洗完澡 if filename == "reward.png": print("洗澡线程停止执行......") return print("洗澡线程停止执行......") return
def loop(hwnd): baseImg = "../images/blackground.jpg" # 储存的文件名 # 储存的文件名 rect = win32gui.GetWindowRect(hwnd) WindowCapture.window_capture(baseImg, hwnd) # 对整个屏幕截图,并保存截图为baseImg # 遍历所有图片 for filename in os.listdir(r"../images/images-fight"): # listdir的参数是文件夹的路径 imagePath = "../images/images-fight/" + filename res = matchImg(baseImg, imagePath, 0.7) if res is None: continue else: x = rect[0] + res["result"][0] y = rect[1] + res["result"][1] move_x = random.randint(int(x) - 2, int(x) + 2) move_y = random.randint(int(y) - 2, int(y) + 2) click_it((move_x, move_y), hwnd)
def loop(hwnd, baseImgPath, imageDirPath): baseImg = baseImgPath # 储存的文件名 rect = win32gui.GetWindowRect(hwnd) WindowCapture.window_capture(baseImg, hwnd) # 对整个屏幕截图,并保存截图为baseImg # 遍历所有图片 for filename in os.listdir(imageDirPath): # listdir的参数是文件夹的路径 imagePath = "../images/images-fight/" + filename res = matchImg(baseImg, imagePath, 0.7) if res is None: continue print(filename) print(res) if filename == "reward.png": x = rect[0] + 20 y = rect[1] + 560 else: x = rect[0] + res["result"][0] y = rect[1] + res["result"][1] move_x = random.randint(int(x) - 2, int(x) + 2) move_y = random.randint(int(y) - 2, int(y) + 2) print(move_x, move_y) click_it((move_x, move_y), hwnd)
def loop(hwnd): baseImg = "../images/blackground.jpg" # 储存的文件名 # 储存的文件名 rect = win32gui.GetWindowRect(hwnd) WindowCapture.window_capture(baseImg, hwnd) # 对整个屏幕截图,并保存截图为baseImg # 遍历所有图片 for filename in os.listdir(r"../images/images-fight"): # listdir的参数是文件夹的路径 imagePath = "../images/images-fight/" + filename res = matchImg(baseImg, imagePath, 0.99) # print("==================:" + filename) if res is None: continue print(filename) #疲劳值满之后,暂停100分钟 if filename == "end.png": print("进入休眠....") time.sleep(1800) print("休眠完成,继续...") x1 = rect[0] + 837 y1 = rect[1] + 207 move_x1 = random.randint(int(x1) - 2, int(x1) + 2) move_y1 = random.randint(int(y1) - 2, int(y1) + 2) click_it((move_x1, move_y1), hwnd) if filename == "00.png": print("发现鬼王.......") x1 = rect[0] + 938 y1 = rect[1] + 140 move_x1 = random.randint(int(x1) - 2, int(x1) + 2) move_y1 = random.randint(int(y1) - 2, int(y1) + 2) click_it((move_x1, move_y1), hwnd) if filename == "reward.png": x = rect[0] + 20 y = rect[1] + 560 else: x = rect[0] + res["result"][0] y = rect[1] + res["result"][1] move_x = random.randint(int(x) - 2, int(x) + 2) move_y = random.randint(int(y) - 2, int(y) + 2) click_it((move_x, move_y), hwnd)
def click_random(point, hwnd): """传入点击坐标 进行随机点击""" rect = win32gui.GetWindowRect(hwnd) x = int(rect[0] + point["result"][0] + (random.randint(1, 3) * 2)) y = int(rect[1] + point["result"][1] + (random.randint(1, 3) * 2)) click_it((x, y), hwnd)