wechat4-auto
DiscoveredSend WeChat 4.x (Windows) messages via OCR + coordinate automation — zero dependencies
wechat4-auto
给 微信 4.x(Windows 桌面版,Weixin.exe) 发消息的零依赖自动化脚本。
Windows 上微信 4.x 客户端用 Qt + 自研 MMUI 渲染,几乎不暴露 UI-Automation 控件树,导致
uiautomation/pywinauto这类老工具失效。本工具改用 「Windows 内置 OCR 读屏 + 屏幕坐标注入」 的方式,不依赖 Hook、不依赖协议、不需要安装任何第三方库。
特性
- ✅ 零依赖:仅需 Windows 10/11 + 系统自带 Windows PowerShell 5.1
- ✅ 中文识别:调用系统内置 OCR(
Windows.Media.Ocr,zh-Hans-CN) - ✅ 中文输入:剪贴板 +
Ctrl+V,绕开输入法(IME)问题 - ✅ 发送前/后 OCR 校验:发送前确认文本已进输入框,发送后再复核
- ✅ 纯函数式模块:可
Import-Module复用,也可直接用命令行脚本
快速开始
# 1) 打开微信 4.x 并登录,手动点开要发送的好友聊天(或确保目标好友在左侧最近会话里)
# 2) 给「当前打开的聊天」发送消息
powershell -ExecutionPolicy Bypass -File .\send-wechat.ps1 -Message "吃完饭后打三角洲吗?"
# 3) 给指定好友发送(实验性:需目标好友出现在左侧最近会话列表)
powershell -ExecutionPolicy Bypass -File .\send-wechat.ps1 -Message "晚上一起打三角洲" -To "肖文博"
或作为模块使用:
Import-Module .\WechatAuto.psm1
Send-WechatMessage -Message "你好" -To "肖文博" # 发给指定好友(实验性)
Send-WechatMessage -Message "你好" # 发给当前聊天
工作流程
Get-WechatWindow—— 按「类名前缀Qt+ 进程Weixin.exe/WeChat.exe」定位微信主窗口Read-WechatScreen—— 置前台 → 截屏 → 系统 OCR 读屏,返回每行文字的坐标和内容- 通过 OCR 找到右下角「发送」按钮作为锚点,反推输入框位置
Send-WechatClick点击输入框 →Send-WechatPaste剪贴板粘贴中文 →Enter发送- 发送前/后各做一次 OCR 校验,文本对不上就中止
环境要求
| 项 | 要求 |
|---|---|
| 系统 | Windows 10 / 11 |
| 终端 | Windows PowerShell 5.1(系统自带) |
| 微信 | 4.x 桌面版(Weixin.exe),需已登录 |
| 中文 OCR | 系统需装有「中文(简体)」语言包(一般中文系统自带) |
⚠️ 重要注意事项
- 输入注入可能被拦截:某些沙箱环境或安全软件(如 HIPS 类防护)会拦截
SetCursorPos/keybd_event(表现为光标不动、按键无效)。请用非沙箱/管理员权限的 PowerShell 运行。 - 屏幕不能锁屏/最小化:本工具依赖真实屏幕内容,微信窗口需可见且不最小化。
- DPI 缩放:脚本内部调用
SetProcessDPIAware(),坐标统一为物理像素,无需手动换算。 -To为实验性功能:目前只支持从左侧「最近会话」列表里按可见文字点击;不在列表里的好友请先手动打开聊天,再用不带-To的方式发送。- 坐标可能需校准:不同分辨率/字体缩放下输入框位置略有差异,可用
-InputX/-InputY手动指定,或参考原理说明中的锚点推导。
局限
- 只做了文本发送(图片/文件/表情未覆盖)。
- 发送结果的 OCR 校验是尽力而为,OCR 对个别字形(如「饭/反」「角」)可能识别偏差,极端情况下可能误报。
- 未实现消息监听/接收。
免责声明
本工具仅供学习、研究与个人自动化使用,请遵守微信《软件许可及服务协议》及相关法律法规,勿用于批量营销、骚扰、外挂等用途。使用本工具产生的任何后果由使用者自行承担。
相关项目
| 项目 | 路线 | 微信版本 |
|---|---|---|
| wxauto | UIA 自动化 | 3.x |
| wxautox4 | UIA 自动化(需授权) | 4.0.5 |
| WeChatFerry | Hook / DLL 注入 | 3.x |
| wechat-automation-api | Flask + uiautomation | 4.0+ |
| omni-bot-sdk-oss | YOLO + OCR + DB | 4.0 |
| 本项目 wechat4-auto | OCR + 坐标 | 4.x |
License
English
wechat4-auto is a zero-dependency PowerShell tool that sends text messages via the WeChat 4.x desktop client on Windows.
The WeChat 4.x client renders its UI with a custom Qt/MMUI surface that exposes almost no UI-Automation tree, so classic uiautomation-based tools break. This project instead reads the screen with the built-in Windows OCR and injects mouse/keyboard through plain user32 P/Invoke — no hooks, no third-party dependencies.
# send to the currently open chat
powershell -ExecutionPolicy Bypass -File .\send-wechat.ps1 -Message "Hello"
# send to a contact visible in the recent-chat list (experimental)
powershell -ExecutionPolicy Bypass -File .\send-wechat.ps1 -Message "Hello" -To "Bob"
See docs/how-it-works.md for the technical write-up. MIT licensed.
Comments
Loading…
Similar plugins
Local WeChat OCR tool for DSH: `wechat_ocr_recognize` returns recognized text and the engine structured result for a local image path.
★ 0
dsh plugin --profile web add dsh-wechat-ocrby Jesse-njx
Chat with, monitor, and approve your DSH agents from WeChat — an iLink gateway + conversation node bundle for DeepSeek Harness
★ 6
MIT
TypeScript
Aug 28, 2026
dsh plugin --profile web add @dsh-cowork/chatnode-wechatby kongdexu
Vertical message pointer rail on the left edge of the chat: one dash per user message, click to scroll to that message, hover for a preview bubble.
★ 3
↓ 98/wk
MIT
TypeScript
Aug 31, 2026
dsh plugin --profile web add dsh-nav-pointerby jingyi0605
把外部 Agent CLI、持久终端、工作区调试和远程访问,装进 DSH 原生界面。
★ 30
GPL-3.0
TypeScript
Oct 11, 2026
dsh plugin --profile web add @jingyi0605/codingns4dshby good-boy4069
Drive your dsh agent from WeChat over the iLink gateway: two-way encrypted media transfer (auto-decrypt inbox + /send), proactive weixin_send tool, completion notifications, multi-session switching, a
★ 1
↓ 95/wk
MIT
TypeScript
Aug 16, 2026
dsh plugin --profile web add dsh-mobile-remoteby xcisxc29
WeChat channel for DeepSeek Harness
★ 92
MIT
TypeScript
Oct 8, 2026
dsh plugin --profile web add dsh-wechat-workspace