docs: restructure markdown docs and publish the bridge
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""Send a TTS voice message through WeChat: focus, voice mode, real hold, play, release."""
|
||||
import asyncio
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.path.insert(0, r"C:\Users\GuoAn\.dsh\wechat-bridge")
|
||||
import wechat_uia as w # noqa: E402
|
||||
import wx_audio # 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"
|
||||
WAV = sys.argv[1] if len(sys.argv) > 1 else r"C:\Users\GuoAn\.dsh\wechat-bridge\tmp\tts_1794648113.wav"
|
||||
|
||||
|
||||
async def main():
|
||||
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()
|
||||
w.focus_window(ch.hwnd)
|
||||
print("focus fg=", w.user32.GetForegroundWindow())
|
||||
img = await ch.snapshot()
|
||||
print("input:", repr(await ch.input_text(img)))
|
||||
if not await ch.voice_ready():
|
||||
mx, my = ch._mic_point(img)
|
||||
ch._click(ch.hwnd, mx, my)
|
||||
await asyncio.sleep(1.0)
|
||||
img = await ch.snapshot()
|
||||
print("after mic:", repr(await ch.input_text(img)))
|
||||
g = ch._geo(img)
|
||||
bx = (g["pane_x0"] + g["pane_right"]) // 2
|
||||
by = int(g["h"] * 0.86)
|
||||
w.focus_window(ch.hwnd)
|
||||
w.real_down(ch.hwnd, bx, by)
|
||||
await asyncio.sleep(0.9)
|
||||
img = await ch.snapshot()
|
||||
mid = await ch.input_text(img)
|
||||
img.save(rf"{TMP}\v_mid.png")
|
||||
print("mid:", repr(mid))
|
||||
await asyncio.to_thread(wx_audio.play_wav, WAV, None, True)
|
||||
await asyncio.sleep(1.2)
|
||||
w.real_up()
|
||||
await asyncio.sleep(2.0)
|
||||
img = await ch.snapshot()
|
||||
img.save(rf"{TMP}\v_end.png")
|
||||
print("end:", repr(await ch.input_text(img)))
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user