adb偷取蚂蚁森林能量

先放效果图 

效果图

代码如下  需要图片素材的在附件里

import os
import sys
import aircv as ac
import time
bashPath = "D:/Tools/adb1/py/pic/"
sys.path.append("D:\Tools\adb1")

#os.popen("adb shell am start -n com.eg.android.AlipayGphone/com.eg.android.AlipayGphone.AlipayLogin")

hight, width = 2000, 1000


def doMatch(source, target):  
    imsrc = ac.imread(source)
    imobj = ac.imread(target)
    matchResult = ac.find_template(imsrc, imobj,0.7)
    return matchResult


def clickXY(x, y):
    os.system("adb  shell input tap "+str(x)+" "+str(y))


def screenShot():
    os.system("adb shell screencap -p /sdcard/t3.png")
    time.sleep(0.4)
    os.system("adb pull /sdcard/t3.png "+bashPath+"screen.png")


def swipe(ox, oy, tx, ty):
    os.system("adb shell input swipe "+str(ox) +
              " "+str(oy)+" "+str(tx)+" "+str(ty))




def checkPic(path):
    screenShot()
    matchResult = doMatch(bashPath+"screen.png", bashPath+path)
    if matchResult:
        
        return True
    return False
def clickPic(path, x=0, y=0):
    screenShot()
    matchResult = doMatch(bashPath+"screen.png", bashPath+path)
    if matchResult:
        clickXY(matchResult['result'][0]+float(x),
                matchResult['result'][1]+float(y))
        return True
    return False


def clickPicArray(paths, x=0, y=0):
    screenShot()
    for p in paths:
        matchResult = doMatch(bashPath+"screen.png", bashPath+p)
        if matchResult:
            clickXY(matchResult['result'][0]+float(x),
                    matchResult['result'][1]+float(y))
            return True
    return False


def swipe1_8():
    ox = width/2
    tx = ox
    oy = hight/2
    ty = hight/8
    swipe(ox, oy, tx, ty)


# swipe1_4()
# clickPic("alipay_help.png")


def mysl():
    os.system("adb connect 10.128.107.129")
    # 检测锁屏

    while True:
        print("打开蚂蚁森林 .")
        os.system(
            "adb shell am start -n com.eg.android.AlipayGphone/com.eg.android.AlipayGphone.AlipayLogin")
        clickPic('1.png')
        clickPic('2.png')
        flag = checkPic('3.png')
        if not flag:
            time.sleep(2)
        else:
            break
    #自己能量收集
    while True:
        flag1 = clickPicArray(["g.png"])
        if not flag1:
            time.sleep(1)
            break

    # 滑动到更多好友
    flag = False
    while not flag:
        print("打开好友列表 .")
        swipe1_8()
        time.sleep(1)
        if(checkPic("4.png")):
            flag = clickPic("4.png")
    flag = False
    while not flag:
        print("循环收取 .")
        if(checkPic("9.png")):
            while True:
                flag1 = clickPicArray(["7.png","8.png","81.png"], y=-10)
                if not flag1:
                    os.system("adb shell input keyevent BACK")
                    time.sleep(1)
                    break
        if(checkPic("5.png")):
            time.sleep(1)
            clickPic("5.png")
        elif(checkPic("6.png")):
            time.sleep(1)
            clickPic("6.png")
        else:
            swipe1_8()
            time.sleep(1)
            continue

        if checkPic("10.png"):
            break


mysl()

 附件 链接: https://pan.baidu.com/s/1c25p5tzbtQZkmaN0NQ0GIA 提取码: 7ihj

猜你喜欢

转载自blog.csdn.net/qq_21078159/article/details/107227474
今日推荐