Files

37 lines
1.2 KiB
Python

"""Step-by-step diagnostic for the WeChat talk button."""
import asyncio
import sys
sys.path.insert(0, r"C:\Users\GuoAn\.dsh\wechat-bridge")
import wechat_uia as w # noqa: E402
from winsdk.windows.globalization import Language # noqa: E402
from winsdk.windows.media.ocr import OcrEngine # noqa: E402
TMP = r"C:\Users\GuoAn\AppData\Local\Temp"
async def main() -> None:
ch = w.WeChatChannel(lambda e: None, 8_000_000_000_000, 8_100_000_000_000)
ch._ocr = OcrEngine.try_create_from_language(Language("zh-Hans-CN"))
ch._ensure_window()
img = await ch.snapshot()
img.save(rf"{TMP}\dbg1.png")
print("step1 title:", await ch.chat_title(img), "input:", await ch.input_text(img))
mx, my = ch._mic_point(img)
print("mic point", mx, my)
ch._click(ch.hwnd, mx, my)
await asyncio.sleep(0.9)
img2 = await ch.snapshot()
img2.save(rf"{TMP}\dbg2.png")
print("step2 input:", await ch.input_text(img2))
d = await ch._press_talk()
print("press diff:", d)
img3 = await ch.snapshot()
img3.save(rf"{TMP}\dbg3.png")
print("step3 input:", await ch.input_text(img3))
w.real_up()
await asyncio.sleep(1.0)
asyncio.run(main())