深夜提醒

现在是深夜,建议您注意休息,不要熬夜哦~

🏮 🏮 🏮

新年快乐

祝君万事如意心想事成!

share-image
中
ESC

OpenClaw Automates WeChat Moments: Unlocking New Tricks for WeChat on Linux

English 阅读中文版

Let an AI assistant post to WeChat Moments for you—freeing your hands while keeping you socially active.

Introduction

As a developer who’s used Ubuntu for a long time, WeChat’s experience on Linux has always been a pain point. Although Tencent officially released a Linux version of WeChat, its features are still relatively barebones compared to the Windows/Mac versions, not to mention any open API.

But as a heavy OpenClaw user, I’ve been wondering: could OpenClaw post to WeChat Moments for me? The answer is yes. Through GUI automation, we can have OpenClaw simulate manual operations to auto-post to WeChat Moments.


Choosing the technical approach

Why can’t we just call an API?

The WeChat Linux client provides no official API, and WeChat Web was discontinued long ago. So unlike Feishu, we can’t just call an interface to send messages.

GUI automation: xdotool

xdotool is a powerful X11 automation tool that can:

  • Simulate mouse clicks and movement
  • Simulate keyboard input
  • Manage windows (find, activate, move, etc.)
  • Get window geometry information

Paired with xclip for handling Chinese input, we can perfectly simulate the manual operation flow.


The implementation

Overall architecture

User instruction (natural language)
↓
OpenClaw Skill parsing
↓
send-wechat-moments script
↓
xdotool automated actions
↓
WeChat client posts to Moments

Core script design

I created two core tools:

Tool Function
wechat-moments-config Calibrate screen coordinates, save the config file
send-wechat-moments Execute the automated Moments-posting flow

Detailed implementation steps

Step one: install dependencies

sudo apt-get update
sudo apt-get install -y xdotool xclip
  • xdotool: the core X11 automation tool
  • xclip: a command-line clipboard tool, used for inputting Chinese

Step two: calibrate coordinates

Since everyone’s screen resolution and WeChat window position differ, we need to calibrate the coordinates of key positions first:

~/.openclaw/tools/wechat-moments-config

This interactive script will guide you through the following steps:

  1. Moments icon position - the Discover/Moments entry in WeChat’s left sidebar
  2. Camera button position - the publish button in the top-right of the Moments page
  3. Text input area - the position of the text input box
  4. Publish button position - the publish confirmation button in the top-right

Once configuration is complete, the coordinates are saved to ~/.openclaw/tools/wechat-moments.conf.

Step three: the posting script

The core script send-wechat-moments workflow:

#!/bin/bash
# 1. Check whether WeChat is running
# 2. Activate the WeChat window
# 3. Click the Moments icon
# 4. Click the camera button
# 5. Input the text content (Chinese via clipboard)
# 6. Add images (optional)
# 7. Click the publish button

Key snippet - window activation:

# Find the WeChat window in several ways
WINDOW_ID=$(xdotool search --name "微信" 2>/dev/null | head -1)
if [ -z "$WINDOW_ID" ]; then
WINDOW_ID=$(xdotool search --name "WeChat" 2>/dev/null | head -1)
fi
if [ -z "$WINDOW_ID" ]; then
WINDOW_ID=$(xdotool search --class "WeChat" 2>/dev/null | head -1)
fi

# Activate and raise the window
xdotool windowactivate "$WINDOW_ID"
xdotool windowraise "$WINDOW_ID"

Key snippet - Chinese input:

# Input Chinese via the clipboard
echo -n "$TEXT" | xclip -selection clipboard
xdotool key ctrl+v

Directly typing Chinese is a hard problem in X11 automation; going through the clipboard is the most reliable way.


How to use it

Direct command-line use

# Post a text-only Moments entry
~/.openclaw/tools/send-wechat-moments -t "Learning OpenClaw today, so fun!"

# Post a text-and-image Moments entry
~/.openclaw/tools/send-wechat-moments -t "Weekend outing" -i ~/Pictures/photo.jpg

Integrating into OpenClaw

Create a Skill config file ~/.openclaw/skills/wechat-moments/SKILL.md:

## Use case

When the user wants to post to Moments, publish text to Moments, or share an image to Moments.

## Example

**User**: Post a Moments entry for me: "Learned something new today!"

**Command**:
```bash
~/.openclaw/tools/send-wechat-moments -t "Learned something new today!"

That way, you just say to OpenClaw:

> "Post a Moments entry for me: ran 10 km today, feels great!"

OpenClaw will automatically call the script to publish it for you.

---

## Live demo

Let's look at a complete interaction flow:

User: Kimi, post a Moments entry for me with the caption “Finally got OpenClaw posting to Moments working!”

OpenClaw:
📱 Activating the WeChat window…
✓ WeChat window activated
📷 Opening the publish interface…
✓ Publish interface opened
⌨️ Typing the text…
✓ Text entered
🚀 Publishing…
✓ Publish complete

✅ Moments posted successfully!
Content: Finally got OpenClaw posting to Moments working!


---

## Notes and limitations

### ⚠️ Please note when using

1. **Don't touch the mouse or keyboard during posting**, or the automation will be interrupted.
2. **The WeChat window must stay visible**; it can't be covered by other windows or minimized.
3. **The coordinates are screen-relative**; after moving the window or changing the resolution you'll need to reconfigure.
4. **Chinese depends on xclip**; make sure it's installed correctly.

### 🔒 Security considerations

- This approach executes only locally and does not involve uploading your WeChat account or password to the cloud.
- All operations run on your already-logged-in WeChat client.
- It does not break WeChat's security limits; it merely simulates manual clicks.

### 🐛 Known limitations

- The WeChat client must stay running.
- If WeChat's UI gets a major redesign, the coordinates may need updating.
- It can't retrieve the publishing result status (whether it succeeded, the number of likes, etc.).

---

## Advanced tricks

### Combined with scheduled tasks

You can pair it with cron to post to Moments on a schedule:

```bash
# Post a good-morning Moments entry every day at 8 a.m.
0 8 * * * /home/wenjun/.openclaw/tools/send-wechat-moments -t "Good morning! $(date +%Y-%m-%d)" >> /tmp/moments.log 2>&1

Combined with AI-generated content

Have OpenClaw first call AI to generate the Moments caption, then auto-publish:

User: Generate a Moments entry about the rain today and publish it

OpenClaw:
1. Call Gemini to generate the caption → "The city on a rainy day has a charm all its own..."
2. Call send-wechat-moments to publish

Multi-account support

If you have multiple WeChat accounts, you can create multiple config files:

~/.openclaw/tools/send-wechat-moments -c ~/.openclaw/tools/wechat-moments-work.conf -t "Work account test"
~/.openclaw/tools/send-wechat-moments -c ~/.openclaw/tools/wechat-moments-personal.conf -t "Personal account test"

Full code

The complete scripts have been uploaded to a GitHub Gist; you can copy them directly:

# Create directories
mkdir -p ~/.openclaw/tools ~/.openclaw/skills/wechat-moments

# Download the config tool
curl -o ~/.openclaw/tools/wechat-moments-config \
https://gist.githubusercontent.com/yourname/wechat-moments-config
chmod +x ~/.openclaw/tools/wechat-moments-config

# Download the main tool
curl -o ~/.openclaw/tools/send-wechat-moments \
https://gist.githubusercontent.com/yourname/send-wechat-moments
chmod +x ~/.openclaw/tools/send-wechat-moments

Summary

By combining xdotool and OpenClaw, we’ve successfully implemented auto-posting to WeChat Moments in a Linux environment. Although this is just a GUI-automation workaround, it’s a practical and reliable solution given that WeChat offers no official API.

The core value of this approach lies in:

  1. Automating repetitive operations - freeing your hands
  2. AI-driven - combining with OpenClaw’s natural language understanding
  3. Extensible - can be further integrated with scheduled tasks, AI content generation, etc.

I hope this write-up helps friends who also use WeChat on Linux!


Related resources:

Happy hacking! 🚀

文章作者:阿文
文章链接: https://www.awen.me/post/d6af6d0f.html
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 阿文的博客!
本文于 2026-03-03 08:00 发布,已超过半年(228天),请注意甄别内容是否已过期。

评论

0 条评论
😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️✋ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐⛎ ♈♉♊ ♋♌♍ ♎♏♐ ♑♒♓ 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘❌⭕ 🛑⛔📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭❗ ❕❓❔ ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️✅ 🈯💹❇️ ✳️❎🌐 💠Ⓜ️🌀 💤🏧🚾 ♿🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️
加载中...

留言反馈

😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️✋ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐⛎ ♈♉♊ ♋♌♍ ♎♏♐ ♑♒♓ 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘❌⭕ 🛑⛔📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭❗ ❕❓❔ ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️✅ 🈯💹❇️ ✳️❎🌐 💠Ⓜ️🌀 💤🏧🚾 ♿🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️