Today, I have finished writing the code for collecting gold coins. It can adapt to different resolutions. The principle is to simulate a hand to click, which is equivalent to running a button wizard on a mobile phone.
Prerequisites for use:
- The adb tool is configured on the computer.
- The phone opens the developer options.
- Installed mobile Taobao.
- Mobile Taobao is the standard version, not the elder version and other versions.
- Taobao did not do activities. Occasionally, the location of gold mining coins may change when encountering events.
- Click here to get the complete project code
# _*_ encoding:utf-8 _*_
import os
import re
import time
base_sr = (1080, 2242)
base_bn1 = (567, 489) # 淘金币按钮
base_bn2 = (515, 1662) # 领取淘金币
def get_resolution():
p = os.popen("adb shell wm size")
result = p.read()
pat = r'\d+'
resolution = re.findall(pat, result)
s = tuple([int(i) for i in resolution])
return s
def coor_cover(old_resolution, old_coor, new_resolution):
return round(new_resolution[0]*old_coor[0]/old_resolution[0]), \
round(new_resolution[1]*old_coor[1]/old_resolution[1])
current_sr = get_resolution()
if current_sr == base_sr:
current_bn1 = base_bn1
current_bn2 = base_bn2
else:
current_bn1 = coor_cover(base_sr, base_bn1, current_sr)
current_bn2 = coor_cover(base_sr, base_bn2, current_sr)
def click(position):
shell = f"adb shell input tap {position[0]} {position[1]}"
os.system(shell)
# 启动淘宝
os.system("adb shell am start -n com.taobao.taobao/com.taobao.tao.TBMainActivity")
time.sleep(7)
# 点击首页领淘金币按钮
click(current_bn1)
time.sleep(5)
# 点击淘金币页的“签到领取”,但实际上不用点击这个按钮也是能领到淘金币的
# click(current_bn2)
# print(current_bn2)