# cluic/wxauto architecture

> Architecture diagram of the GitHub repository cluic/wxauto, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cluic/wxauto
- Repository: https://github.com/cluic/wxauto

## Overview

##### Project type and purpose
- From the README and file tree, “wxauto” is a Python UI-Automation library/tool for controlling the Windows WeChat client.
- It provides high-level APIs (e.g., WeChat.SendMsg(), GetAllMessage(), AddListenChat()) that wrap lower-level UI Automation and Win32 calls to drive WeChat’s GUI.

##### File structure
- Top-level:
- pyproject.toml – build/config for Python packaging
- README.md, LICENSE, .gitignore
- Core modules under “wxauto/”:
- wx.py – likely hosts the public WeChat class and entry point
- exceptions.py, logger.py, languages.py, param.py – shared utilities
- msgs/ – message model classes (base, friend, self, type, attr)
- ui/ – GUI component abstractions:
– base.py (generic UI element wrapper)
– main.py (main window wrapper)
– navigationbox.py, sessionbox.py, chatbox.py, component.py
- uiautomation.py – direct integration with the UIAutomation library
- utils/ – support functions (tools.py, win32.py)

##### README for additional insights
- The README describes Python 3.9+, Windows10+, WeChat3.9.X.
- It shows usage patterns (initialization, sending, listening).
- Public API → internal core → UIAutomation → Windows → WeChat client

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    User["User Code / Scripts"]:::user

    %% Public API Layer
    subgraph "Public API"
        WeChat["WeChat (wxauto/wx.py)"]:::public
    end

    %% Core Modules Layer
    subgraph "Core Modules"
        subgraph "Message Model Layer"
            Base["base.py"]:::model
            Friend["friend.py"]:::model
            SelfMsg["self.py"]:::model
            Attr["attr.py"]:::model
            Type["type.py"]:::model
            Msg["msg.py"]:::model
        end
        subgraph "UI Component Layer"
            UIBase["base.py"]:::ui
            Component["component.py"]:::ui
            Main["main.py"]:::ui
            Nav["navigationbox.py"]:::ui
            Sess["sessionbox.py"]:::ui
            Chat["chatbox.py"]:::ui
        end
        subgraph "Utility & Configuration Layer"
            Ex["exceptions.py"]:::util
            Log["logger.py"]:::util
            Lang["languages.py"]:::util
            Param["param.py"]:::util
            Tools["tools.py"]:::util
        end
    end

    %% Engine and Adapter Layers
    UIAuto["uiautomation.py"]:::engine
    Win32["win32.py"]:::adapter

    %% External Systems
    subgraph "External Systems"
        WinOS["Windows OS"]:::external
        WeChatApp["WeChat GUI App"]:::external
    end

    %% Relationships
    User -->|"calls methods"| WeChat
    WeChat -->|"serialize/deserialize"| Base
    WeChat -->|"serialize/deserialize"| Friend
    WeChat -->|"serialize/deserialize"| SelfMsg
    WeChat -->|"serialize/deserialize"| Attr
    WeChat -->|"serialize/deserialize"| Type
    WeChat -->|"serialize/deserialize"| Msg
    WeChat -->|"locate UI elements"| UIBase
    WeChat -->|"locate UI elements"| Component
    WeChat -->|"locate UI elements"| Main
    WeChat -->|"locate UI elements"| Nav
    WeChat -->|"locate UI elements"| Sess
    WeChat -->|"locate UI elements"| Chat
    WeChat -->|"configuration & logging"| Ex
    WeChat -->|"configuration & logging"| Log
    WeChat -->|"configuration & logging"| Lang
    WeChat -->|"configuration & logging"| Param
    WeChat -->|"configuration & logging"| Tools
    WeChat -->|"execute UI actions"| UIAuto
    UIAuto -->|"COM calls"| WeChatApp
    UIAuto -->|"fallback to Win32"| Win32
    Win32 -->|"Win32 API calls"| WeChatApp
    WeChatApp -->|"GUI events"| UIAuto
    Base -->|"objects"| WeChat
    Friend -->|"objects"| WeChat
    SelfMsg -->|"objects"| WeChat
    Attr -->|"objects"| WeChat
    Type -->|"objects"| WeChat
    Msg -->|"objects"| WeChat
    WeChat -->|"returns results"| User

    %% Click Events
    click WeChat "https://github.com/cluic/wxauto/blob/main/wxauto/wx.py"
    click Base "https://github.com/cluic/wxauto/blob/main/wxauto/msgs/base.py"
    click Friend "https://github.com/cluic/wxauto/blob/main/wxauto/msgs/friend.py"
    click SelfMsg "https://github.com/cluic/wxauto/blob/main/wxauto/msgs/self.py"
    click Attr "https://github.com/cluic/wxauto/blob/main/wxauto/msgs/attr.py"
    click Type "https://github.com/cluic/wxauto/blob/main/wxauto/msgs/type.py"
    click Msg "https://github.com/cluic/wxauto/blob/main/wxauto/msgs/msg.py"
    click UIBase "https://github.com/cluic/wxauto/blob/main/wxauto/ui/base.py"
    click Component "https://github.com/cluic/wxauto/blob/main/wxauto/ui/component.py"
    click Main "https://github.com/cluic/wxauto/blob/main/wxauto/ui/main.py"
    click Nav "https://github.com/cluic/wxauto/blob/main/wxauto/ui/navigationbox.py"
    click Sess "https://github.com/cluic/wxauto/blob/main/wxauto/ui/sessionbox.py"
    click Chat "https://github.com/cluic/wxauto/blob/main/wxauto/ui/chatbox.py"
    click Ex "https://github.com/cluic/wxauto/blob/main/wxauto/exceptions.py"
    click Log "https://github.com/cluic/wxauto/blob/main/wxauto/logger.py"
    click Lang "https://github.com/cluic/wxauto/blob/main/wxauto/languages.py"
    click Param "https://github.com/cluic/wxauto/blob/main/wxauto/param.py"
    click Tools "https://github.com/cluic/wxauto/blob/main/wxauto/utils/tools.py"
    click UIAuto "https://github.com/cluic/wxauto/blob/main/wxauto/uiautomation.py"
    click Win32 "https://github.com/cluic/wxauto/blob/main/wxauto/utils/win32.py"

    %% Styles
    classDef user fill:#e0ffe0,stroke:#333,stroke-width:1px;
    classDef public fill:#a2f5a2,stroke:#333,stroke-width:1px;
    classDef model fill:#a2c8f5,stroke:#333,stroke-width:1px;
    classDef ui fill:#f5d76a,stroke:#333,stroke-width:1px;
    classDef util fill:#f5a2f5,stroke:#333,stroke-width:1px;
    classDef engine fill:#d3d3d3,stroke:#333,stroke-width:1px;
    classDef adapter fill:#d3d3d3,stroke:#333,stroke-width:1px;
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px;
```
