# 创作者: anjdeng
# !/usr/bin/python
# -*- coding: UTF-8 -*-
import pyautogui
import win32gui
import win32con
import time
import random
import goto
from goto import with_goto
import pytesseract as pt
from PIL import Image
hwnd = win32gui.FindWindow('LDPlayerMainFrame','雷电模拟器')
win32gui.ShowWindow(hwnd,win32con.SW_SHOWDEFAULT)
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
list = [left,top,right,bottom]
print("%d" % list[0])
worklist = ['师门','宝图']
def 点击活动():
pyautogui.click(list[0]+random.randint(295,340),list[1]+random.randint(40,90),duration=2)
return
def 识别任务(x,y):
#保存截图
im = pyautogui.screenshot(region=(list[0] + 395 + x, list[1] + 130 + y,125,40))#x加380就是第二列 y加110第二行
im.save('做活动.png')
#识别文字
path = r"E:\tesseract-ocr\tesseract.exe"
pt.pytesseract.tesseract_cmd = path
img = Image.open("做活动.png")
arm = pt.image_to_string(img,lang="chi_sim")
time.sleep(2)
print(arm)
test1 = '宝图'
for i in test1:
if i in arm:
return 1
return 0
def 找任务(x, y, i,it):
if it == 0:
if i == 0:
i = i + 1
it = 识别任务(x,y)
return 找任务(x,y,i,it)
else:
if i % 2 != 0:
i = i + 1
x = x + 380
it = 识别任务(x, y)
return 找任务(x,y,i,it)
else:
i = i + 1
x = x - 380
y = y + 105
it = 识别任务(x, y)
return 找任务(x,y,i,it)
else:
i = i - 1
return i
def 识别任务列表(d):
im = pyautogui.screenshot(region=(list[0] +966, list[1] + 200,100,35)) # x加380就是第二列
im.save('任务列表.png')
path = r"E:\tesseract-ocr\tesseract.exe"
pt.pytesseract.tesseract_cmd = path
img = Image.open("任务列表.png")
arm = pt.image_to_string(img, lang="chi_sim")
time.sleep(2)
return
def 点参加(x,y):
pyautogui.click(list[0] + random.randint(590,665) + x, list[1] + random.randint(145,165) + y, duration=2)
time.sleep(7)
#领取任务
pyautogui.click(list[0] + random.randint(890,1130), list[1] + random.randint(445,480), duration=2)
return
def 做任务(d):
if d == 0:
pyautogui.click(list[0] + random.randint(970,1080), list[1] + random.randint(200, 280), duration=2)
pyautogui.moveTo(list[0] + random.randint(510,700), list[1] + random.randint(340, 440), duration=2)
pyautogui.click(list[0] + random.randint(970, 1080), list[1] + random.randint(200, 280), duration=2)
elif d == 1:
pyautogui.click(list[0] + random.randint(970, 1080), list[1] + random.randint(290, 360), duration=2)
pyautogui.moveTo(list[0] + random.randint(510, 700), list[1] + random.randint(340, 440), duration=2)
pyautogui.click(list[0] + random.randint(970, 1080), list[1] + random.randint(290, 360), duration=2)
time.sleep(2)
点击活动()
time.sleep(0.5)
i = 0
x = 0
y = 0
it = 0
it = 找任务(x,y,i,it)
time.sleep(0.5)
x = 0
y = 0
if it == 0:
点参加(x,y)
elif it == 1:
点参加(x+385,y)
elif it == 2:
点参加(x,y+105)
elif it == 3:
点参加(x+385,y+105)
elif it == 4:
点参加(x,y+210)
elif it == 5:
点参加(x+385,y+210)
else:
print("错误")
time.sleep(0.5)
d = 0
d = 识别任务列表(d)
time.sleep(0.5)
做任务(d)
用python做梦幻手游刷宝图脚本
于 2022-01-01 13:43:26 首次发布