← 返回
未分类

Wechat Automation

微信RPA自动化技能。基于pywechat3(pip install pywechat127)实现Windows PC微信自动化操作,包括发消息、批量群发、读取聊天记录、获取通讯录、自动回复、朋友圈管理等。当用户需要操作微信(发消息、查记录、自动回复等)时激活。
微信RPA自动化,基于pywechat3(pip install pywechat127)在Windows PC上实现微信自动化操作:发消息、批量群发、读取聊天记录、获取通讯录、自动回复、朋友圈管理等。在需要操作微信时激活。
838997125 838997125 来源
未分类 clawhub v1.1.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 392
下载
💾 0
安装
1
版本
#latest

概述

WeChat Automation Skill

环境要求

  • 操作系统:Windows 10/11
  • 微信版本:PC微信 3.9.12.x / 4.0+
  • Python:3.x
  • 依赖pip install pywechat127 emoji pyautogui pywinauto pyperclip psutil pywin32

一键安装

在 OpenClaw 终端执行一次:

pip install pywechat127 emoji pyautogui pywinauto pyperclip psutil pywin32

注意:OpenClaw 运行在沙箱时需要微信安装在标准路径,且与 OpenClaw 同桌面会话。首次使用前先运行环境检查:

python "C:\Users\HUAWEI\.openclaw\workspace\skills\wechat-automation\scripts\check_env.py"

核心功能(直接调用,无需生成脚本)

发送消息

import sys
sys.path.insert(0, r'D:\code\pywechat3')
from pywechat.WechatAuto import Messages

# 单人单条
Messages.send_message_to_friend(
    friend="好友备注",
    message="消息内容",
    close_wechat=True
)

# 单人多条
Messages.send_messages_to_friend(
    friend="好友备注",
    messages=["消息1", "消息2"],
    delay=0.4
)

批量发送(给不同好友发不同消息)

from pywechat.WechatAuto import Messages

Messages.send_messages_to_friends(
    friends=["好友1", "好友2"],
    messages=[["消息A"], ["消息B"]],
    delay=0.4
)

发送文件

from pywechat.WechatAuto import Files

Files.send_file_to_friend(
    friend="好友备注",
    file_path=r"C:\path\to\file.pdf"
)

读取聊天记录

from pywechat.WechatTools import Tools

contents, senders, types = Tools.pull_messages(
    friend="好友备注",
    number=200
)

获取通讯录

from pywechat.WechatAuto import Contacts

# 好友列表
friends = Contacts.get_friends_info()

# 群聊列表
groups = Contacts.get_groups_info()

监听新消息

from pywechat.WechatAuto import Messages

new_messages = Messages.check_new_message(
    duration="5min",
    save_file=True
)

自动回复(装饰器)

from pywechat.utils import auto_reply_to_friend_decorator

@auto_reply_to_friend_decorator(duration="30min", friend="好友备注")
def reply_func(newMessage):
    if "在吗" in newMessage:
        return "你好,我暂时不在"
    return "收到"

reply_func()

技术原理

  • UI 自动化pywinauto(Windows 原生 UI Automation API)
  • 输入模拟pyautogui(剪贴板复制 → Ctrl+V 粘贴 → Alt+S 发送)
  • 发消息:复制内容到剪贴板 → 粘贴到微信输入框 → 发送快捷键
  • 无 Hook / 无内存读取:纯物理 UI 模拟,微信无法检测

错误处理

错误原因解决
------------------
WeChatNotStartError微信未启动先手动打开微信
ElementNotFoundError微信版本不兼容更新 pywechat 或检查 UI 元素
NotInstalledError未找到微信注册表确认微信 3.9+ 已安装
NoSuchFriendError好友备注不匹配检查精确备注名

参考

  • PyPI:https://pypi.org/project/pywechat127/
  • 源码:https://github.com/Hello-Mr-Crab/pywechat
  • 本地源码:D:\code\pywechat3

版本历史

共 1 个版本

  • v1.1.0 当前
    2026-05-07 08:35 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,423 📥 326,130
ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 850 📥 330,932
ai-agent

self-improving agent

pskoett
记录自身发现以实现自我改进的技能
★ 4,130 📥 892,130