This skill implements automated sending of WeChat messages on macOS via an AppleScript script.
Feature Overview
- Automatically activate the WeChat app
- Search for a specified contact or group
- Send the specified message content
- Supports Chinese and special characters
Usage
How to Invoke
osascript scripts/wechat_automation_script.applescript "<用户名>" "<消息内容>"
Parameter Description
| Parameter | Required | Description |
|---|---|---|
| Username | Yes | WeChat contact name or group name, must match exactly |
| Message content | Yes | The message text to send |
Usage Example
# 发送消息给好友
osascript scripts/wechat_automation_script.applescript "张三" "你好,今天有空吗?"
# 发送消息到群组
osascript scripts/wechat_automation_script.applescript "工作群" "大家好!"
# 发送包含中文的消息
osascript scripts/wechat_automation_script.applescript "Yatocala" "hello你好"
Workflow
- Activate WeChat - Bring the WeChat window to the front
- Open search - Use
Cmd+Fto open the contact search box - Search contact - Paste the username and select the first matching result
- Focus the input box - Ensure focus is on the input box via the Tab key and clicking
- Send message - Paste the message content and press Enter to send
- Hide window - Hide the WeChat window after sending is complete
Notes
- WeChat must already be logged in - Ensure the WeChat app is logged in before execution
- Contact names must match exactly - The first matching result will be selected during search
- Execution takes about 15 seconds - The script contains multiple delays to ensure stability
- Accessibility permission is required - System Events accessibility permission must be granted on first use
Permission Configuration
If the script fails to execute, check the following permissions:
- System Preferences → Security & Privacy → Privacy
- Select Accessibility
- Ensure the following apps have been added and checked:
- Terminal (or the terminal app you use)
- System Events
Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| Message not sent | Focus is not on the input box | Check whether the number of Tab key presses is sufficient |
| Contact cannot be found | Name does not match | Confirm that the contact name matches exactly |
| Script execution interrupted | Insufficient permissions | Check accessibility permissions |
| Chinese characters appear garbled when sent | Encoding issue | Ensure the terminal uses UTF-8 encoding |
File Structure
wechat-message/
├── SKILL.md # 主说明文档
├── template.md # 消息模板
├── examples/
│ └── sample.md # 使用示例
└── scripts/
└── wechat_automation_script.applescript # AppleScript 脚本