Goal
Call scripts/send_wechat_message.swiftto send a plain text message to a specified contact in WeChat Desktop on macOS.
Required parameters
contact: contact display name, which must exactly match the WeChat conversation title.message: the plain text content to send.
Prerequisites
- WeChat Desktop is installed.
- The current terminal or Codex has been granted macOS Accessibility permissions.
- Only text messages are supported; images, files, and cards are not supported.
Workflow
- Validate that
contactandmessageare non-empty. - Run the script:
swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>"
- The script will automatically:
- Open or activate WeChat.
- Focus the search box on the left and search for the contact.
- Look for an exact match in the results list.
- After opening the conversation, verify again that the title exactly equals
contact。 - After validation passes, send the message.
Debugging
- Only verify locating, without actually sending:
swift scripts/send_wechat_message.swift --contact "<contact>" --message "<message>" --dry-run
Safety rules
- Only exact title matches are accepted; no fuzzy guessing.
- If the contact cannot be found, permissions are insufficient, or the window structure is abnormal, report an error directly and stop.
- If the script reports a structure error, first confirm that WeChat has been upgraded to the latest version and re-authorize Accessibility.