xmks
修改方法:
A 截图,找到关键图截取
B 重新截图,找到关键图所在位置图标(xx=100,yy=200)
C找到关键区域(80,300,160,300)
D 根据关键图位置图标计算关键区域坐标(xx-20,yy+100,xx+60,yy+100)
E 找到关键区域中关键色(画图--吸管-吸取相应颜色,编辑颜色 255,73,6)
F 在关键区域查找关键色出现的色块数量,只要色块数量不变表示积分不长了,以此判断进行滑屏
xmfba.png #红色:255,73,6
def wmjca(xha,sjh,mubiao,xxa,xx=0,yy=0): end1=time.perf_counter() pull_screenshot(xha,sjh,xxa) # 截图 end4=time.perf_counter() if end4-end1>60: return 0,0,0 temp='./tmall'+str(xxa)+'.png' imsrc = ac.imread(temp) # 原始图像 imsch = ac.imread(mubiao) # 带查找的部分 aa=ac.find_template(imsrc, imsch)# #aa={'result': (90.0, 429.0), 'rectangle': ((73, 413), (73, 445), (107, 413), (107, 445)), 'confidence': 0.9999932646751404} #result为找到目标的中心坐标, #rectangle为找到目标的左上,左下,右上,右下坐标 #confidence:相似度 if (aa!=None): end2=time.perf_counter() if end2-end1>60: return 0,0,0 xx=aa['result'][0] yy=aa['result'][1] print(1,xx-80,yy-24,xx+51,yy+117) img=Image.open(temp) img1=img.crop((xx-80,yy-24,xx+51,yy+117)) #img1=img[340:480,20:160] #img1.save("xxv.png") #im=np.array(Image.open(img).convert('RGB')) im=np.array(img1.convert('RGB')) sought = [255,73,6]#红色颜色的特征 result = np.count_nonzero(np.all(im==sought,axis=2))#统计图形中红色的比例 print(result) #plt.imshow(img1) #plt.show()#前后二行结合显示指定图片 return result,xx,yy else: end3=time.perf_counter() if end3-end1>60: return 0,0,0 print(xx-80,yy-24,xx+51,yy+117) img=Image.open(temp) img1=img.crop((xx-80,yy-24,xx+51,yy+117)) #im=np.array(Image.open(img).convert('RGB')) im=np.array(img1.convert('RGB')) sought = [255,73,6]#红色颜色的特征 result = np.count_nonzero(np.all(im==sought,axis=2))#统计图形中红色的比例 print(result) #plt.imshow(img1) #plt.show()#前后二行结合显示指定图片 return result,xx,yy
def matcha(bb,aa):#从bb查找aa,如果有则返回其坐标位置 aa="./tmall"+str(aa)+".png" yuan=ac.imread(bb) mubi=ac.imread(aa) result=ac.find_template(yuan,mubi,0.2)#0.7相似度 if(result!=None): return result['result'][0],result['result'][1] #return yuan.shape[1],yuan.shape[0] return None def hua10new(): print("begin") ci=0 for ii in range(1,20): abc=0 #int(random.uniform(3,8)) start=time.perf_counter() if not jianchaada(sjh): break while 1: aa=aaa=aa1=aaa1=(0,0,0) #ci=ci+1 print(datetime.datetime.now()) if ci%10==0: if not jianchaadaa(sjh): break ah=int(random.uniform(3,7)) end=time.perf_counter() if end-start>120: break abc=abc+1 tua=["./xmfba.png","./xmyuan.png"] tub=["./xmkshb.png"] if abc%2==0: if matcha("./xmfba.png",2): aa=wmjca(2,sjh,"./xmfba.png",2) if matcha("./xmyuan.png",2): aaa=wmjc(2,sjh,"./xmyuan.png",2) else: if matcha("./xmfba.png",2): aa1=wmjca(2,sjh,"./xmfba.png",2) if matcha("./xmyuan.png",2): aaa1=wmjc(2,sjh,"./xmyuan.png",2) print(aa,aa1,aaa,aaa1) #break if (abs(aaa1[0]-aaa[0])<=5): ci=ci+1 time.sleep(5+ah) huadong(sjh) break elif abs(aa[0]-aa1[0])<=5: ci=ci+1 time.sleep(5+ah) huadong(sjh) break time.sleep(1) print("end")
sjh="pvq4nrx4kzemw4ca" ##sjh="192.168.0.103:5555" #sjh="172.16.0.17:5555" #sjh="172.16.130.48:5555" #sjh="172.16.130.14:5555" #sjh="192.168.0.101:5555" ##sjh="172.16.130.142:5555" #sjh="MGFVB20723011474" ak='adb -s {0} shell input keyevent 4'.format(sjh)#返回 aka='adb -s {0} shell input swipe 400 500 400 200'.format(sjh)#滑动 akaa='adb -s {0} shell input swipe 400 500 400 400'.format(sjh)#滑动 akb="adb -s {0} shell input tap 500 70".format(sjh)#退出直播 akc="adb -s {0} shell input tap 270 560".format(sjh)#关注退出直播 akd="adb -s {0} shell input tap 270 640".format(sjh)#不关注退出直播 ake="adb -s {0} shell input tap 250 690".format(sjh)#开宝箱 akf="adb -s {0} shell input tap 90 310".format(sjh)#开宝箱 akg="adb -s {0} shell input tap 300 750".format(sjh)#直播1 akh="adb -s {0} shell input tap 800 750".format(sjh)#直播2 aki="adb -s {0} shell input tap 300 1750".format(sjh)#直播3 akj="adb -s {0} shell input tap 800 1750".format(sjh)#直播4 akga="adb -s {0} shell input tap 300 950".format(sjh)#直播1 akha="adb -s {0} shell input tap 800 950".format(sjh)#直播2 akia="adb -s {0} shell input tap 300 1650".format(sjh)#直播3 akja="adb -s {0} shell input tap 800 1650".format(sjh)#直播4 akjb1="adb -s {0} shell input tap 200 1450".format(sjh)#小说1 akjb2="adb -s {0} shell input tap 400 1450".format(sjh)#小说2 akjb3="adb -s {0} shell input tap 600 1450".format(sjh)#小说3 akjb4="adb -s {0} shell input tap 900 1450".format(sjh)#小说4 ahh="adb -s {0} shell input tap 500 1000".format(sjh) ahha="adb -s {0} shell input tap 200 510".format(sjh) ahhb="adb -s {0} shell input tap 520 2120".format(sjh) ahhc="adb -s {0} shell input tap 920 2110".format(sjh) pull_screenshot(2,sjh,2) #jianchaad(sjh) kssj1=time.perf_counter() #sys.exit(0) while 1: print("ci=",datetime.datetime.now()) kssj2=time.perf_counter() if kssj2-kssj1>60: kssj1=time.perf_counter() continue huaa(sjh)
def huaa(sjh): aa=aaa=aa1=aaa1=ax=ay=(0,0,0) abc=0 #int(random.uniform(3,8)) start=time.perf_counter() ci=0 while 1: if ci!=0: pull_screenshot(2,sjh,2) ci=ci+1 print(datetime.datetime.now()) ah=int(random.uniform(3,6)) end=time.perf_counter() if end-start>120: break abc=abc+1 tua=["./xmfba.png","./xmyuan.png"] tub=["./xmkshb.png"] if abc%2==0: if matcha("./xmfba.png",2): aa=wmjca(2,sjh,"./xmfba.png",2) elif matcha("./xmyuan.png",2): aa=wmjc(2,sjh,"./xmyuan.png",2) ax=aa else: if matcha("./xmfba.png",2): aa1=wmjca(2,sjh,"./xmfba.png",2) elif matcha("./xmyuan.png",2): aa1=wmjc(2,sjh,"./xmyuan.png",2) ay=aa1 print(ax,ay) #break if abs(ax[0]-ay[0])<=5: #time.sleep(ah) huadong(sjh) time.sleep(ah) #break
def matcha(bb,aa):#从bb查找aa,如果有则返回其坐标位置 aa="./tmall"+str(aa)+".png" yuan=ac.imread(bb) #try: mubi=ac.imread(aa) #except: # return None result=ac.find_template(yuan,mubi,0.3)#0.7相似度 if(result!=None): return result['result'][0],result['result'][1] #return yuan.shape[1],yuan.shape[0] return None