初始化
This commit is contained in:
31
demo.py
Normal file
31
demo.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
wxauto 最简单的 demo 测试
|
||||
需要先安装: pip install wxauto
|
||||
确保微信客户端已登录
|
||||
"""
|
||||
|
||||
from wxauto import WeChat
|
||||
|
||||
# 初始化微信实例
|
||||
print("正在初始化微信...")
|
||||
wx = WeChat()
|
||||
|
||||
# 发送消息到文件传输助手
|
||||
print("正在发送消息...")
|
||||
wx.SendMsg("你好,这是一条测试消息!", who="文件传输助手")
|
||||
|
||||
# 获取当前聊天窗口的消息
|
||||
print("正在获取消息...")
|
||||
msgs = wx.GetAllMessage()
|
||||
|
||||
# 打印消息信息
|
||||
print(f"\n共获取到 {len(msgs)} 条消息:")
|
||||
for i, msg in enumerate(msgs, 1):
|
||||
print(f"消息 {i}:")
|
||||
print(f" 内容: {msg.content}")
|
||||
print(f" 类型: {msg.type}")
|
||||
print(f" 发送者: {msg.sender}")
|
||||
print()
|
||||
|
||||
print("Demo 测试完成!")
|
||||
|
||||
Reference in New Issue
Block a user