pip install pywechat127 emoji pyautogui pywinauto pyperclip psutil pywin32在 OpenClaw 终端执行一次:
bash
pip install pywechat127 emoji pyautogui pywinauto pyperclip psutil pywin32
注意:OpenClaw 运行在沙箱时需要微信安装在标准路径,且与 OpenClaw 同桌面会话。首次使用前先运行环境检查:
bash
python "C:\Users\HUAWEI\.openclaw\workspace\skills\wechat-automation\scripts\check_env.py"
python
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
)
python
from pywechat.WechatAuto import Messages
Messages.send_messages_to_friends(
friends=["好友1", "好友2"],
messages=[["消息A"], ["消息B"]],
delay=0.4
)
python
from pywechat.WechatAuto import Files
Files.send_file_to_friend(
friend="好友备注",
file_path=r"C:\path\to\file.pdf"
)
python
from pywechat.WechatTools import Tools
contents, senders, types = Tools.pull_messages(
friend="好友备注",
number=200
)
python
from pywechat.WechatAuto import Contacts
# 好友列表
friends = Contacts.get_friends_info()
# 群聊列表
groups = Contacts.get_groups_info()
python
from pywechat.WechatAuto import Messages
new_messages = Messages.check_new_message(
duration="5min",
save_file=True
)
python
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()
pywinauto(Windows 原生 UI Automation API)pyautogui(剪贴板复制 → Ctrl+V 粘贴 → Alt+S 发送)错误原因解决WeChatNotStartError微信未启动先手动打开微信ElementNotFoundError微信版本不兼容更新 pywechat 或检查 UI 元素NotInstalledError未找到微信注册表确认微信 3.9+ 已安装NoSuchFriendError好友备注不匹配检查精确备注名
D:\code\pywechat3