Skip to main content

WinAutoWx 针对 Weixin/WeChat 自动化脚本 支持 LLM 的 MCP

本项目提供一个基于 Python + pywinauto 的自动化脚本,可在 Windows 上连接/启动微信(Weixin/WeChat),搜索好友或群聊并发送消息,支持一次性向多个好友循环发送多条消息。

交流群

赞赏

启动指令速查

  • 命令行(CLI 用法已迁移至 Debug 文档) 请参考 Debug.md 获取 run_wechat.py 的命令行用法与调试说明。

  • 启动 HTTP API 服务(FastAPI)

uvicorn server:app --host 127.0.0.1 --port 8000
  • 启动 fastmcp(MCP/stdio)服务并用 MCP Inspector 连接
python mcp_server.py
mcp-inspector --server "python mcp_server.py"

环境要求

  • Windows 10/11(64 位推荐)
  • Python 3.8–3.12(64 位推荐)
  • 已安装并登录 Windows 版微信(Weixin/WeChat)

安装

pip install -r requirements.txt

快速上手

若需要通过命令行快速发送或调试,请查看 Debug.md。以下为通过 HTTP API/MCP 的方式:

参数说明(CLI)

命令行参数表已迁移至 Debug.md

常见用法示例(CLI)

命令行示例已迁移至 Debug.md

通过 API 调用(FastAPI / fastmcp 2.0)

已提供 server.py,可作为本地服务供 AI/HTTP 调用。

  • 启动服务:
uvicorn server:app --host 127.0.0.1 --port 8000
  • 发送消息接口:POST http://127.0.0.1:8000/send
{
  "friends": ["文件传输助手"],
  "messages": ["测试一下"],
  "backend": "win32",
  "ctrl_enter": false,
  "friend_delay": 0.5,
  "message_delay": 0.2,
  "no_launch": false,
  "verbose": true
}
  • 导出控件接口:POST http://127.0.0.1:8000/dump
{
  "backend": "win32",
  "verbose": true
}

说明:脚本主体位于 script/wechat_sender.py。命令行使用说明见 Debug.md;HTTP 接口由 server.py 提供。

通过 fastmcp(MCP/stdio 协议)

已提供 mcp_server.py(基于 fastmcp 2.0)。它是一个 MCP 服务器,通过标准输入输出(stdio)对外暴露工具。内部会把工具调用转发到上面的 HTTP 服务。

  1. 安装依赖并启动 HTTP 服务:
pip install -r requirements.txt
uvicorn server:app --host 127.0.0.1 --port 8000
  1. 启动 MCP 服务器(stdio):
python mcp_server.py
  1. -用 MCP Inspector 连接:-(废弃)
mcp-inspector --server "python mcp_server.py"

工具说明:

  • send_messages(friends, messages, backend='uia'|'win32', ctrl_enter=False, friend_delay=0.5, message_delay=0.2, no_launch=False, verbose=False)
  • dump_controls(backend='uia'|'win32', verbose=True)

可用环境变量:

  • WEIXIN_API_URL:转发的 HTTP 服务地址(默认 http://127.0.0.1:8000

MCP Inspector 配置

  1. 先启动 HTTP 服务(新终端):
uvicorn server:app --host 127.0.0.1 --port 8000

npx @modelcontextprotocol/inspector

  1. 在 MCP Inspector 中填写:
  • Server command:
python mcp_server.py
  • Working Directory:
D:\代码存储\winautowx
  • Environment variables(可选):
    • WEIXIN_API_URL: http://127.0.0.1:8000
  • Arguments: 留空
  • Transport: 默认 stdio(保持不变)
  • 点击 Connect
  1. 在 Inspector 中调用 tools:
  • send_messages 示例参数:
{
  "friends": ["文件传输助手"],
  "messages": ["测试一下"],
  "backend": "win32",
  "ctrl_enter": false,
  "friend_delay": 0.5,
  "message_delay": 0.2,
  "no_launch": false,
  "verbose": true
}
  • dump_controls 示例参数:
{
  "backend": "win32",
  "verbose": true
}

使用建议

  • 保持微信主窗口处于当前桌面且未最小化。
  • 先用“文件传输助手”验证流程,避免打扰他人。
  • 若你的微信版本为新版 Weixin(进程 Weixin.exe),脚本已适配。
  • 特殊布局或企业微信可能与控件结构不同,遇到问题请开 --verbose 并将输出粘贴给我。

免责声明

  • 此脚本仅用于学习与个人效率用途。请遵守相关平台使用条款,避免滥用自动化操作。

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_winautowx-1.0.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_winautowx-1.0.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_winautowx-1.0.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_winautowx-1.0.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_winautowx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5af9996a9a6909ba52e0e17e11735af21d7e13f0116d11e1f09329add257544d
MD5 35ea48b7f09f12af36d5f6c86a1073c7
BLAKE2b-256 b6890a4be60634a3562523152e2aeb5814b2e45c65e7a3515f3753d737274171

See more details on using hashes here.

File details

Details for the file iflow_mcp_winautowx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_winautowx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_winautowx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 291c1114ef365754ef09d5fff037ecbee53caf453d5745e2829bb75691f4ff8e
MD5 9bfe411b57e51f218740d7c02c92e63d
BLAKE2b-256 794e87b40f8bb18f6a129afe386e6f6061ccdce21fcb46cdf4c1db5fd1687c85

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page