wechat-message-sender

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WeChat Message Sender

WeChat Message Sender

目标

Objective

调用
scripts/send_wechat_message.swift
,在 macOS 微信桌面版里给指定联系人发送一段纯文本。
Call
scripts/send_wechat_message.swift
to send a plain text message to a specified contact in the WeChat desktop client on macOS.

必填参数

Required Parameters

  • contact
    :联系人显示名,必须与微信会话标题精确一致。
  • message
    :要发送的纯文本内容。
  • contact
    : The display name of the contact, which must exactly match the WeChat session title.
  • message
    : The plain text content to be sent.

前置条件

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

  1. 校验
    contact
    message
    非空。
  2. 运行脚本:
    • swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>"
  3. 脚本会自动:
    • 打开或激活微信。
    • 聚焦左侧搜索框并搜索联系人。
    • 在结果列表里查找精确匹配项。
    • 打开会话后再次校验标题完全等于
      contact
    • 校验通过后发送消息。
  1. Verify that
    contact
    and
    message
    are not empty.
  2. Run the script:
    • swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>"
  3. 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
      contact
      again after opening the session.
    • 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.