بنقرة واحدة
微信(WeChat)桌面客户端操作指南。通过 macOS osascript + screencapture 实现读取消息和发送消息。当用户提到微信、WeChat、发消息、聊天时自动激活。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
微信(WeChat)桌面客户端操作指南。通过 macOS osascript + screencapture 实现读取消息和发送消息。当用户提到微信、WeChat、发消息、聊天时自动激活。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | |
| description | 微信(WeChat)桌面客户端操作指南。通过 macOS osascript + screencapture 实现读取消息和发送消息。当用户提到微信、WeChat、发消息、聊天时自动激活。 |
| argument-hint | ["操作描述,如\"回复盏\" \"看看微信有什么新消息\" \"给xx发条消息\" \"大猫猫来微信\""] |
当妈妈说**「大猫猫来微信」**时,进入微信聊天模式:
wechat-poll 后台轮询(每8秒检查新消息)TaskOutput 阻塞等待轮询结果(timeout 180秒)sleep 2 && wechat-poll 重启轮询# 读消息
wechat-query '<python代码>'
# 轮询等新消息(后台运行)
wechat-poll <chat_username> [interval_seconds]
# 例:wechat-poll arthas_9156 8
sleep 2 再启动轮询,避免把自己的消息误捕为新消息timestamp字段)判断新消息,不是 create_time[图片] 标记盏和她的Claude做的微信群聊AI总结工具可以直接解密并读取微信本地SQLite数据库,比截图方式快几十倍且100%准确。
# 工具目录
WECHAT_TOOL_DIR = "/Users/arthas/Desktop/Synergia/Claude/微信项目/wechat-summary-share 3"
VENV_PYTHON = f"{WECHAT_TOOL_DIR}/.venv/bin/python"
# 初始化代码(每次使用时运行)
import json, sys
sys.path.insert(0, WECHAT_TOOL_DIR)
from core.wechat_db import WeChatDB
with open('/Users/arthas/.wechat-summary/config.json') as f:
cfg = json.load(f)
with open('/Users/arthas/.wechat-summary/all_keys.json') as f:
keys = json.load(f)
db = WeChatDB(cfg['db_dir'], keys)
已创建包装脚本 ~/.local/bin/wechat-query,自动 cd 到工具目录并调用 venv Python,避免中文路径导致的权限弹框问题:
wechat-query '
import json, sys
sys.path.insert(0, ".")
from core.wechat_db import WeChatDB
with open("/Users/arthas/.wechat-summary/config.json") as f:
cfg = json.load(f)
with open("/Users/arthas/.wechat-summary/all_keys.json") as f:
keys = json.load(f)
db = WeChatDB(cfg["db_dir"], keys)
# 在这里写查询逻辑...
# 注意:f-string 里不能用反斜杠转义,需要先把字典值赋给变量
'
注意:wechat-query 内部用单引号包裹 Python 代码,所以代码里要用双引号。f-string 中不能直接用 m[\"key\"],需要先提取到变量再用。
sessions = db.get_recent_sessions(limit=20)
for s in sessions:
tag = '群' if s['is_group'] else '私'
print(f'[{tag}] {s["name"]} - {s["time_str"]} - {s["summary"][:50]}')
# 按群名查找
groups = db.get_groups()
target = None
for g in groups:
if '赛克斯' in g['name']: # 模糊匹配群名
target = g['username']
break
# 读取最近N条消息
msgs = db.get_messages(target, limit=50)
for m in msgs:
sender = m['sender'] if m['sender'] else '鹅鹅' # 空sender = Synqa自己
print(f'[{m["time_str"]}] {sender}: {m["text"]}')
import time
since = int(time.time()) - 3600 # 最近1小时
msgs = db.get_messages(target, since_ts=since, limit=500)
from datetime import datetime
groups = db.get_groups()
usernames = [g['username'] for g in groups] # 所有群
start_ts = datetime(2026, 3, 1).timestamp()
end_ts = datetime(2026, 3, 10).timestamp()
results = db.search_messages(['关键词1', '关键词2'], usernames, start_ts, end_ts)
username = db.resolve_username('盏') # 支持群名、备注名、昵称
all_keys.json 为空 {},说明密钥尚未提取成功。首次配置(已完成过一次,记录在此以备将来需要):
# 1. 创建venv并安装依赖
cd "/Users/arthas/Desktop/Synergia/Claude/微信项目/wechat-summary-share 3"
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
# 2. 重签名微信(去掉hardened runtime,需要sudo密码)
# 先退出微信!
sudo codesign --force --deep --sign - /Applications/WeChat.app
# 3. 重启微信,然后通过菜单栏app提取密钥
# 或者手动运行:
sudo ./.wechat-summary/find_keys_macos <WeChat_PID>
# 4. 如果C扫描器找到keys但匹配0个DB(root读不了沙箱),手动用Python匹配:
.venv/bin/python -c "
import os, json
DATA = os.path.expanduser('~/.wechat-summary')
# ... (解析log中的key+salt,读取db文件头的salt,匹配后写入all_keys.json)
"
{}:密钥未提取。确保微信正在运行且已重签名,然后重新提取。sudo chown arthas:staff ~/.wechat-summary/all_keys.json发送消息仍然需要通过osascript操控微信UI,因为数据库是只读的。
osascript 设置系统剪贴板 → 点击输入框 → Cmd+V 粘贴 → Return 发送osascript + System Events 操作窗口焦点、位置、点击screencapture 截图确认System Events 操作会报错 -25211osascript -e '
tell application "WeChat"
activate
reopen
end tell'
osascript -e '
tell application "System Events"
tell process "WeChat"
set frontmost to true
set winPos to position of window 1
set winSize to size of window 1
return "Pos: " & (item 1 of winPos) & "," & (item 2 of winPos) & " Size: " & (item 1 of winSize) & "x" & (item 2 of winSize)
end tell
end tell'
osascript <<'ASCRIPT'
set the clipboard to "要发送的消息内容"
tell application "System Events"
tell process "WeChat"
set frontmost to true
delay 0.3
click at {输入框X坐标, 输入框Y坐标}
delay 0.3
keystroke "v" using command down
delay 0.3
key code 36
end tell
end tell
ASCRIPT
# 使用搜索框
osascript <<'ASCRIPT'
set the clipboard to "联系人名字"
tell application "System Events"
tell process "WeChat"
set frontmost to true
delay 0.2
click at {搜索框X, 搜索框Y}
delay 0.3
keystroke "v" using command down
delay 0.5
-- 搜索结果出来后截图确认,再点击对应联系人
end tell
end tell
ASCRIPT
# 截取整个微信窗口(先用上面的命令获取X,Y,W,H)
screencapture -x -R{X},{Y},{W},{H} /tmp/wechat_window.png
然后用 Read 工具查看截图确认状态。
# 正确 ✅
osascript -e 'set the clipboard to "你好世界"'
# 错误 ❌ —— pbcopy 对中文编码有问题
echo -n "你好世界" | pbcopy
猫猫颜文字 ฅ^•ﻌ•^ฅ 中的泰文字符经过 osascript 剪贴板后会乱码。签名用纯 ASCII:(Claude Code · Sylux the Lynx)
keystroke "你好" 会被输入法拦截。永远用剪贴板粘贴。
osascript <<'ASCRIPT'
set the clipboard to "包含'单引号'的文本"
...
ASCRIPT
┌──────────────────────────────────────┐
│ 左侧栏(约1/3) │ 聊天区域(约2/3) │
│ ┌────────────┐ │ ┌──────────────┐ │
│ │ 搜索框 │ │ │ 聊天标题栏 │ │
│ ├────────────┤ │ ├──────────────┤ │
│ │ │ │ │ │ │
│ │ 聊天列表 │ │ │ 消息区域 │ │
│ │ │ │ ├──────────────┤ │
│ │ │ │ │ 工具栏图标 │ │
│ │ │ │ ├──────────────┤ │
│ │ │ │ │ 文字输入框 │ │
│ └────────────┘ │ └──────────────┘ │
└──────────────────────────────────────┘
输入框位置估算:窗口 (X, Y) 大小 (W, H)
(X + W*0.55, Y + H*0.96)(X + W*0.17, Y + 50)activate 微信并获取窗口坐标pbcopy 写入中文。用 osascript 的 set the clipboard tokeystroke 打中文。会被输入法拦截