调整项目结构
This commit is contained in:
@@ -1,46 +1,41 @@
|
||||
import cv2
|
||||
import lxml
|
||||
import wda
|
||||
from lxml import etree
|
||||
|
||||
from script.AiTools import AiTools
|
||||
import wda
|
||||
|
||||
from Utils.AiUtils import AiUtils
|
||||
|
||||
|
||||
# 脚本管理类
|
||||
class ScriptManager():
|
||||
|
||||
# 单利对象
|
||||
_instance = None # 类变量,用于存储单例实例
|
||||
|
||||
def __new__(cls):
|
||||
# 如果实例不存在,则创建一个新实例
|
||||
if cls._instance is None:
|
||||
cls._instance = super(ScriptManager, cls).__new__(cls)
|
||||
# 返回已存在的实例
|
||||
return cls._instance
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# 脚本开关
|
||||
self.running = False
|
||||
self.initialized = True # 标记已初始化
|
||||
|
||||
# 养号
|
||||
@classmethod
|
||||
def growAccount(self, udid):
|
||||
client = wda.USBClient(udid)
|
||||
session = client.session()
|
||||
session.appium_settings({"snapshotMaxDepth": 0})
|
||||
|
||||
# deviceWidth = client.window_size().width
|
||||
# deviceHeight = client.window_size().height
|
||||
|
||||
img = client.screenshot()
|
||||
tempPath = "resources/bgv.jpg"
|
||||
img.save(tempPath)
|
||||
|
||||
smallImage = AiTools.pathWithName("like")
|
||||
bigImage = AiTools.pathWithName("bgv")
|
||||
|
||||
x, y = AiTools.find_image_in_image(bigImage, smallImage)
|
||||
print(x, y)
|
||||
# client.tap(x, y)
|
||||
|
||||
|
||||
# xml = session.source()
|
||||
# print(xml)
|
||||
# root = etree.fromstring(xml.encode('utf-8'))
|
||||
# try:
|
||||
# msg = client.xpath('label="收件箱"')
|
||||
# msg.click()
|
||||
# print(msg)
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
session.appium_settings({"snapshotMaxDepth": 15})
|
||||
numberLabel = session.xpath("//*[@name='a11y_vo_inbox']")
|
||||
if numberLabel:
|
||||
content = numberLabel.label
|
||||
number = AiUtils.findNumber(content)
|
||||
print(number)
|
||||
else:
|
||||
print("没找到")
|
||||
|
||||
manager = ScriptManager()
|
||||
manager.growAccount("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user