wechat-message
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese微信消息发送技能
WeChat Message Sending Skill
此技能通过平台脚本实现微信消息的自动化发送:macOS 使用 AppleScript + cliclick,Windows 使用 PowerShell。按当前操作系统选用对应脚本即可。
This skill realizes automatic sending of WeChat messages through platform-specific scripts: macOS uses AppleScript + cliclick, Windows uses PowerShell. Just select the corresponding script based on your current operating system.
功能概述
Function Overview
- 自动激活微信应用
- 搜索指定联系人或群组
- 发送指定消息内容
- 支持中文和特殊字符
- Automatically activate the WeChat application
- Search for specified contacts or groups
- Send specified message content
- Support Chinese and special characters
使用方法
Usage
macOS(AppleScript)
macOS (AppleScript)
bash
osascript scripts/wechat_automation_script.applescript "<联系人名称>" "<消息内容>"bash
osascript scripts/wechat_automation_script.applescript "<Contact Name>" "<Message Content>"Windows(PowerShell)
Windows (PowerShell)
powershell
powershell -ExecutionPolicy Bypass -File scripts/wechat_automation_script.ps1 "<联系人名称>" "<消息内容>"powershell
powershell -ExecutionPolicy Bypass -File scripts/wechat_automation_script.ps1 "<Contact Name>" "<Message Content>"参数说明
Parameter Description
| 参数 | 必填 | 说明 |
|---|---|---|
| 联系人名称 | 是 | 微信联系人名称或群名称,需完全匹配 |
| 消息内容 | 是 | 要发送的消息文本 |
| Parameter | Required | Description |
|---|---|---|
| Contact Name | Yes | WeChat contact name or group name, must be an exact match |
| Message Content | Yes | The message text to be sent |
使用示例
Usage Examples
macOS:
bash
osascript scripts/wechat_automation_script.applescript "张三" "你好,今天有空吗?"
osascript scripts/wechat_automation_script.applescript "工作群" "大家好!"Windows:
powershell
powershell -ExecutionPolicy Bypass -File scripts/wechat_automation_script.ps1 "张三" "你好,今天有空吗?"
powershell -ExecutionPolicy Bypass -File scripts/wechat_automation_script.ps1 "工作群" "大家好!"macOS:
bash
osascript scripts/wechat_automation_script.applescript "Zhang San" "Hello, are you free today?"
osascript scripts/wechat_automation_script.applescript "Work Group" "Hello everyone!"Windows:
powershell
powershell -ExecutionPolicy Bypass -File scripts/wechat_automation_script.ps1 "Zhang San" "Hello, are you free today?"
powershell -ExecutionPolicy Bypass -File scripts/wechat_automation_script.ps1 "Work Group" "Hello everyone!"工作流程
Workflow
两平台流程一致,仅快捷键不同:
- 激活微信 - 将微信窗口置于最前
- 打开搜索 - macOS:/ Windows:
Cmd+FCtrl+F - 搜索联系人 - 粘贴联系人名并选择第一个匹配结果(Ctrl+V / Cmd+V)
- 定位输入框 - macOS:cliclick 点击窗口右下角 / Windows:Tab 键定位
- 发送消息 - 粘贴消息内容并按回车发送
- 收尾 - macOS:隐藏窗口 / Windows:最小化窗口
Cmd+H
The workflow is consistent across both platforms, only the shortcut keys differ:
- Activate WeChat - Bring the WeChat window to the front
- Open Search - macOS: / Windows:
Cmd+FCtrl+F - Search for Contact - Paste the contact name and select the first matching result (Ctrl+V / Cmd+V)
- Locate Input Box - macOS: cliclick clicks the bottom right corner of the window / Windows: Locate via Tab key
- Send Message - Paste the message content and press Enter to send
- Wrap Up - macOS: to hide the window / Windows: Minimize the window
Cmd+H
注意事项
Notes
- 微信必须已登录 - 执行前确保微信已打开并登录
- 联系人名称需精确匹配 - 搜索时会选择第一个匹配结果
- 执行时间约 15 秒 - 脚本包含多个延时,执行期间勿操作微信
- macOS:需要安装 cliclick 并授予 辅助功能 权限
- Windows:若提示无法执行脚本,请使用 ;若在微信内修改过「搜索」快捷键,需在
-ExecutionPolicy Bypass中把.ps1改为对应快捷键^f
- WeChat must be logged in - Ensure WeChat is open and logged in before execution
- Contact name must be an exact match - The first matching result will be selected during search
- Execution time is approximately 15 seconds - The script includes multiple delays, do not operate WeChat during execution
- macOS: Need to install cliclick and grant Accessibility permissions
- Windows: If prompted that the script cannot be executed, use ; if you modified the "Search" shortcut key in WeChat, change
-ExecutionPolicy Bypassto the corresponding shortcut key in the^ffile.ps1
权限配置
Permission Configuration
macOS
macOS
1. 安装 cliclick
1. Install cliclick
使用 Homebrew 安装:
bash
brew install cliclickInstall using Homebrew:
bash
brew install cliclick2. 授予辅助功能权限
2. Grant Accessibility Permissions
- 系统设置 → 隐私与安全性 → 辅助功能
- 将 终端(或 iTerm、Cursor 等)加入列表并勾选
- 如有 System Events,建议一并勾选
- System Settings → Privacy & Security → Accessibility
- Add Terminal (or iTerm, Cursor, etc.) to the list and check the box
- If System Events is present, it is recommended to check it as well
Windows
Windows
无需额外权限;首次运行若受限,使用 执行脚本即可。
-ExecutionPolicy BypassNo additional permissions required; if restricted during first run, execute the script with .
-ExecutionPolicy Bypass故障排除
Troubleshooting
| 问题 | 可能原因 | 解决方案 |
|---|---|---|
| 消息未发送 | 焦点未在输入框 | 执行期间勿切换窗口,可重试 |
| 搜索不到联系人 | 名称不匹配 | 确认联系人/群名与微信中完全一致 |
| macOS 脚本无反应 | 未给辅助功能权限 | 在「辅助功能」中勾选终端等应用 |
| macOS 鼠标点击无效 | cliclick 未安装或权限不足 | |
| Windows 无法执行脚本 | 执行策略限制 | 使用 |
| 发送中文乱码 | 编码问题 | 终端使用 UTF-8 编码 |
| Problem | Possible Cause | Solution |
|---|---|---|
| Message not sent | Focus not on input box | Do not switch windows during execution, try again |
| Contact not found | Name does not match | Confirm that the contact/group name is exactly the same as in WeChat |
| macOS script unresponsive | Accessibility permissions not granted | Check Terminal and other applications in "Accessibility" |
| macOS mouse click ineffective | cliclick not installed or insufficient permissions | |
| Windows cannot execute script | Execution policy restriction | Use |
| Garbled Chinese characters when sending | Encoding issue | Use UTF-8 encoding in the terminal |
文件结构
File Structure
wechat-message/
├── SKILL.md # 本技能说明
├── README.md # 使用说明
├── examples/
│ └── sample.md # 使用示例
└── scripts/
├── wechat_automation_script.applescript # macOS 脚本
└── wechat_automation_script.ps1 # Windows 脚本wechat-message/
├── SKILL.md # This skill description
├── README.md # Usage instructions
├── examples/
│ └── sample.md # Usage examples
└── scripts/
├── wechat_automation_script.applescript # macOS script
└── wechat_automation_script.ps1 # Windows script