用python做梦幻手游刷宝图脚本

# 创作者: 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)

  • 1
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AnJunDeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值