Install
openclaw skills install wx-send发送微信消息给指定联系人。支持两种模式:(1) 有消息内容:直接发送指定消息;(2) 无消息内容:OCR 截图识别聊天窗口内容并自动回复。当用户需要自动发送微信消息、自动回复微信聊天时触发此技能。
openclaw skills install wx-send发送微信消息给指定联系人。
通过 AppleScript 模拟键盘操作,自动完成微信消息发送。
通过模拟键盘快捷键控制微信客户端 UI:
| 步骤 | 操作 | 工具/命令 |
|---|---|---|
| 1 | 激活微信应用 | tell application "WeChat" |
| 2 | 复制联系人到剪贴板 | AppleScript set the clipboard to |
| 3 | 打开搜索框 | keystroke "f" using command down |
| 4 | 粘贴联系人名称 | keystroke "v" using command down |
| 5 | 按回车键 | keystroke return |
| 6 | 按下箭头选择搜索结果 | keystroke (ASCII character 31) |
| 7 | 按上箭头取消选择 | keystroke (ASCII character 30) |
| 8 | 再次回车进入聊天 | keystroke return |
| 9 | 复制消息到剪贴板 | AppleScript set the clipboard to |
| 10 | 粘贴消息 | keystroke "v" using command down |
| 11 | 发送消息 | keystroke return |
on run argv
set contactName to item 1 of argv
set messageText to ""
if (count of argv) > 1 then
set messageText to item 2 of argv
end if
tell application "WeChat"
activate
delay 0.5
end tell
set the clipboard to contactName
tell application "System Events"
tell process "WeChat"
-- 打开搜索框 (Cmd+F)
keystroke "f" using command down
delay 1
-- 粘贴联系人名称
keystroke "v" using command down
delay 2
-- 回车
keystroke return
delay 1
-- 按一次下箭头
keystroke (ASCII character 31)
delay 0.5
-- 按一次上箭头
keystroke (ASCII character 30)
delay 0.5
-- 再次回车进入聊天
keystroke return
delay 2
end tell
end tell
if messageText is not "" then
set the clipboard to messageText
tell application "System Events"
tell process "WeChat"
delay 1
-- 粘贴消息
keystroke "v" using command down
delay 0.5
-- 发送
keystroke return
end tell
end tell
return "Sent: " & messageText
else
return "Ready"
end if
end run
# 方法1:复制 wx_send.applescript.txt 内容手动创建 .applescript 文件
# 然后执行:
osascript scripts/wx_send.applescript "联系人名称" "消息内容"
# 方法2:使用 Python 版本
python3 scripts/wx_send.py "联系人名称" "消息内容"
scripts/wx_send.applescript.txt 的内容wx_send.applescript(无后缀)chmod +x wx_send.applescript# 给"怪兽"发送消息"你好"
python3 scripts/wx_send.py "怪兽" "你好"
首次使用需要授权辅助功能权限:
osascript 或终端应用pip3 install pyautogui
如需 OCR 截图识别自动回复,可使用 wx_ocr_reply.py(需要配置 OpenAI API)。