This commit is contained in:
HuangHai
2026-01-17 07:21:21 +08:00
parent a3a77b8333
commit f6fb2ab97f
8 changed files with 97 additions and 18 deletions

View File

@@ -58,17 +58,40 @@ async def open_mini_program():
d.app_start("com.tencent.mm", stop=True)
await asyncio.sleep(5)
# 2. 点击搜索按钮 (坐标适配大部分微信版本)
logger.info("点击搜索按钮...")
w, h = d.window_size()
d.click(int(w * 0.84), int(h * 0.08))
await asyncio.sleep(2)
# 3. 输入搜索内容
logger.info("输入搜索内容: 驿来特")
d.send_keys("驿来特")
try:
d.set_input_ime(True)
except Exception as e:
logger.warning(f"启用 FastInputIME 失败: {e}")
try:
search_bar_x, search_bar_y = int(w * 0.4), int(h * 0.08)
d.click(search_bar_x, search_bar_y)
await asyncio.sleep(1.5)
except Exception as e:
logger.warning(f"点击搜索框以获取焦点失败: {e}")
try:
d.send_keys("驿来特")
except Exception as e:
logger.warning(f"直接 send_keys 失败: {e}")
try:
d(focused=True).set_text("驿来特")
except Exception as e2:
logger.error(f"文字输入彻底失败: {e2}")
await asyncio.sleep(3)
try:
d.set_input_ime(False)
except Exception as e:
logger.warning(f"恢复系统输入法失败: {e}")
# 4. 点击搜索结果中的第一个小程序
logger.info("点击搜索结果中的小程序...")
d.click(int(w * 0.5), int(h * 0.18))