使用uiautomator2实现自动获取蚂蚁森林的绿色能量
程序员文章站
2022-03-08 15:31:52
先上代码# coding: utf-8import uiautomator2 as u2import timed = u2.connect()#d = u2.connect('10.1.21.44')d.app_start("com.eg.android.AlipayGphone")time.sleep(4)d(text="蚂蚁森林").click()time.sleep(3)count = 0while True: count += 1 time.sleep(2...
先上代码
# coding: utf-8
import uiautomator2 as u2
import time
d = u2.connect()
d.app_start("com.eg.android.AlipayGphone")
time.sleep(4)
d(text="蚂蚁森林").click()
time.sleep(3)
count = 0
while True:
count += 1
time.sleep(2)
d.click(0.187, 0.316)
d.click(0.31, 0.279)
d.click(0.44, 0.26)
d.click(0.566, 0.26)
d.click(0.692, 0.278)
d.click(0.799, 0.316)
d.click(0.187, 0.316)
d.click(0.31, 0.279)
d.click(0.44, 0.26)
d.click(0.896, 0.666) # 找能量
if d(text="startapp?appId=20000290&actionType=recommendList&source=by_antforest_potential_friend_list").exists:
d.app_stop("com.eg.android.AlipayGphone")
break
print("能量偷完咯~ 一共偷了", count, "个人")
展示视频
https://www.bilibili.com/video/BV1Ap4y1C7Mi/
话不多说,网上有挺多uiautomator2的配置教程,这里就不罗嗦了,提供一下关键的工具包
本文地址:https://blog.csdn.net/qq_42276781/article/details/111317960