wechat-message-sender
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWeChat Message Sender
WeChat Message Sender
目标
Objective
调用 ,在 macOS 微信桌面版里给指定联系人发送一段纯文本。
scripts/send_wechat_message.swiftCall to send a plain text message to a specified contact in the WeChat desktop client on macOS.
scripts/send_wechat_message.swift必填参数
Required Parameters
- :联系人显示名,必须与微信会话标题精确一致。
contact - :要发送的纯文本内容。
message
- : The display name of the contact, which must exactly match the WeChat session title.
contact - : The plain text content to be sent.
message
前置条件
Prerequisites
- 已安装微信桌面版。
- 当前终端或 Codex 已授予 macOS 辅助功能权限。
- 只支持文本消息,不支持图片、文件、卡片。
- WeChat desktop client has been installed.
- Accessibility permissions have been granted to the current terminal or Codex.
- Only text messages are supported; images, files, and cards are not supported.
工作流
Workflow
- 校验 和
contact非空。message - 运行脚本:
swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>"
- 脚本会自动:
- 打开或激活微信。
- 聚焦左侧搜索框并搜索联系人。
- 在结果列表里查找精确匹配项。
- 打开会话后再次校验标题完全等于 。
contact - 校验通过后发送消息。
- Verify that and
contactare not empty.message - Run the script:
swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>"
- The script will automatically:
- Open or activate WeChat.
- Focus on the left search box and search for the contact.
- Find the exact match in the result list.
- Verify that the title exactly equals again after opening the session.
contact - Send the message after verification passes.
调试
Debugging
- 只验证定位,不真正发送:
swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>" --dry-run
- Verify positioning only without actually sending:
swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>" --dry-run
安全规则
Security Rules
- 只接受精确标题匹配,不做模糊猜测。
- 找不到联系人、权限不足、窗口结构异常时,直接报错并停止。
- 如果脚本报结构错误,先确认微信已升级到最新版本,并重新授权辅助功能。
- Only accept exact title matches; no fuzzy guessing.
- Directly report an error and stop if the contact is not found, permissions are insufficient, or the window structure is abnormal.
- If the script reports a structure error, first confirm that WeChat has been updated to the latest version, and re-authorize accessibility permissions.