win-auto-utils 0.1.0

Universal Windows automation utilities with memory, window, input, and color operations
# Win Auto Utils

[ไธญๆ–‡ๆ–‡ๆกฃ]docs/zh/README.md | [English Documentation]docs/en/README.md

A universal Windows automation utility library providing atomic modules for memory operations, window management, input simulation, and color processing. Built with Rust for performance and safety.

## ๐Ÿš€ Features

### Core Capabilities

- **Process Management**: Process enumeration, handle aggregation, module snapshot (ToolHelp32)
- **Window Operations**: Window handle queries, enumeration, manipulation, DC management
- **Input Simulation**: Keyboard input (Key Down/Up/Press), mouse click & movement
- **Screen Capture**: High-performance DXGI-based capture, GDI color picking
- **Color Processing**: Pure Rust pixel color finding algorithms (zero dependencies)
- **Memory Operations**: Read/write process memory, address resolution, AOB scanning
- **Hooking System**: Inline hooks, trampoline hooks, register extraction
- **Script Engine**: Pure Rust interpreter with control flow, timing, keyboard/mouse instructions
- **DLL Injection**: Cross-architecture injection (x64โ†’x86/x64, WOW64 compatible)
- **Template Matching**: Image-based UI element detection with parallel processing

### Key Advantages

โœ… **Atomic Design**: Enable only what you need via feature flags  
โœ… **Minimal Dependencies**: Core features depend only on `windows` crate  
โœ… **Performance**: Release mode with LTO, size optimization, symbol stripping  
โœ… **Safety**: Rust's ownership system prevents common memory errors  
โœ… **Cross-platform Script Engine**: Pure Rust, no external dependencies  

## ๐Ÿ“ฆ Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
win-auto-utils = { version = "0.1.0", features = ["standard"] }
```

For full functionality including template matching:

```toml
[dependencies]
win-auto-utils = { version = "0.1.0", features = ["full"] }
```

## ๐ŸŽฏ Quick Start

### Process Management

```rust
use win_auto_utils::process::Process;

let process = Process::builder("notepad.exe").build();
process.init()?;
println!("PID: {}", process.get_pid());
```

### Memory Operations

```rust
use win_auto_utils::memory::{read_memory_t, write_memory_t};

// Read a 32-bit integer
let value: i32 = read_memory_t(handle, address)?;

// Write a float value
write_memory_t::<f32>(handle, address, 999.0)?;
```

### Input Simulation

```rust
use win_auto_utils::keyboard::key_press;
use win_auto_utils::mouse::{move_to, left_click};

// Press 'A' key
key_press(handle, 0x41)?;

// Move mouse and click
move_to(handle, 100, 200)?;
left_click(handle)?;
```

### Screen Capture (DXGI)

```rust
use win_auto_utils::dxgi::DxgiCapture;

let mut capture = DxgiCapture::new()?;
let image = capture.capture_window(hwnd)?;
```

### Memory Hooking

```rust
use win_auto_utils::memory_hook::TrampolineHook;

let shellcode = vec![0x01, 0xD2]; // add edx, edx
let mut hook = TrampolineHook::x86(handle, target_addr, shellcode);
hook.install()?;
// ... trigger hook ...
hook.uninstall()?; // Auto-frees memory
```

### Script Engine

```rust
use win_auto_utils::script_engine::ScriptEngine;

let script = r#"
    loop 10
        key VK_SPACE
        sleep 100
    end
"#;

let mut engine = ScriptEngine::new();
engine.execute(script)?;
```

## ๐Ÿ“š Documentation

Comprehensive documentation is available in both English and Chinese:

### Quick Links
- **[Documentation Index (EN)]docs/en/INDEX.md** - Complete navigation guide
- **[ๆ–‡ๆกฃ็ดขๅผ• (ไธญๆ–‡)]docs/zh/INDEX.md** - ๅฎŒๆ•ดๅฏผ่ˆชๆŒ‡ๅ—

### Module Documentation

#### English
- [Modules Overview]docs/en/modules/overview.md - High-level view of all modules
- [Memory Operations]docs/en/modules/memory.md
- [Memory Hooking]docs/en/modules/memory_hook.md
- [Address Resolution]docs/en/modules/memory_resolver.md
- [AOB Scanning]docs/en/modules/memory_aobscan.md
- [Script Engine]docs/en/modules/script_engine.md
- [Input Control]docs/en/modules/input.md
- [Process & Window]docs/en/modules/process_window.md
- [Screen Capture]docs/en/modules/dxgi.md
- [Template Matching]docs/en/modules/template_matcher.md
- [DLL Injection]docs/en/modules/dll_injector.md

#### Chinese (ไธญๆ–‡)
- [ๆจกๅ—ๆฆ‚่งˆ]docs/zh/modules/overview.md - ๆ‰€ๆœ‰ๆจกๅ—็š„้ซ˜ๅฑ‚่ง†ๅ›พ
- [ๅ†…ๅญ˜ๆ“ไฝœ]docs/zh/modules/memory.md
- [ๅ†…ๅญ˜้’ฉๅญ]docs/zh/modules/memory_hook.md
- [ๅœฐๅ€่งฃๆž]docs/zh/modules/memory_resolver.md
- [ๅญ—่Š‚ๆ‰ซๆ]docs/zh/modules/memory_aobscan.md
- [่„šๆœฌๅผ•ๆ“Ž]docs/zh/modules/script_engine.md
- [่พ“ๅ…ฅๆŽงๅˆถ]docs/zh/modules/input.md
- [่ฟ›็จ‹ไธŽ็ช—ๅฃ]docs/zh/modules/process_window.md
- [ๅฑๅน•ๆ•่Žท]docs/zh/modules/dxgi.md
- [ๆจกๆฟๅŒน้…]docs/zh/modules/template_matcher.md
- [DLLๆณจๅ…ฅ]docs/zh/modules/dll_injector.md

## ๐Ÿ—๏ธ Architecture

The library follows a modular architecture with feature-gated components:

```
win-auto-utils/
โ”œโ”€โ”€ Process & Window Layer
โ”‚   โ”œโ”€โ”€ process      - Process management
โ”‚   โ”œโ”€โ”€ hwnd         - Handle queries
โ”‚   โ”œโ”€โ”€ window       - Window manipulation
โ”‚   โ””โ”€โ”€ snapshot     - ToolHelp32 enumeration
โ”‚
โ”œโ”€โ”€ Input Layer
โ”‚   โ”œโ”€โ”€ keyboard     - Keyboard simulation
โ”‚   โ””โ”€โ”€ mouse        - Mouse control
โ”‚
โ”œโ”€โ”€ Graphics Layer
โ”‚   โ”œโ”€โ”€ dxgi         - Screen capture
โ”‚   โ”œโ”€โ”€ color_picker - GDI color picking
โ”‚   โ””โ”€โ”€ color_finder - Pixel color search
โ”‚
โ”œโ”€โ”€ Memory Layer
โ”‚   โ”œโ”€โ”€ memory       - Basic read/write
โ”‚   โ”œโ”€โ”€ memory_resolver - Symbolic addresses
โ”‚   โ”œโ”€โ”€ memory_aobscan  - Pattern scanning
โ”‚   โ””โ”€โ”€ memory_hook     - Inline/trampoline hooks
โ”‚
โ”œโ”€โ”€ Advanced Features
โ”‚   โ”œโ”€โ”€ dll_injector    - DLL injection
โ”‚   โ””โ”€โ”€ template_matcher - Image matching
โ”‚
โ””โ”€โ”€ Script Engine
    โ”œโ”€โ”€ script_engine      - Core interpreter
    โ””โ”€โ”€ scripts_builtin    - Built-in instructions
```

## ๐Ÿ”ง Feature Flags

Choose only what you need:

### Minimal Setup (~15s compilation)
```bash
cargo build --no-default-features --features "keyboard,mouse"
```

### Core Features (default)
```bash
cargo build  # Includes all stable features except template_matcher
```

### Full Features (~45-60s compilation)
```bash
cargo build --no-default-features --features "full"
```

### Available Features

| Feature | Description | Dependencies |
|---------|-------------|--------------|
| `process` | Process management | windows, hwnd, hdc, snapshot, handle |
| `keyboard` | Keyboard input | windows |
| `mouse` | Mouse control | windows |
| `memory` | Memory read/write | windows |
| `memory_hook` | Hooking system | memory, windows |
| `memory_aobscan` | Pattern scanning | memory, memchr, rayon |
| `dxgi` | Screen capture | windows |
| `template_matcher` | Image matching | image, imageproc, rayon |
| `script_engine` | Script interpreter | (none, pure Rust) |
| `dll_injector` | DLL injection | snapshot, windows |

See [Cargo.toml](Cargo.toml) for complete feature list.

## ๐Ÿ“– Examples

Explore the `examples/` directory for usage demonstrations:

```bash
# Run script engine example
cargo run --example script_engine --features "script_engine"

# Run DXGI capture example
cargo run --example dxgi_capture --features "dxgi"

# Run memory hook example
cargo run --example memory_hook_reset --features "memory_hook"

# Run AOB scan benchmark
cargo run --example aobscan_benchmark --features "memory_aobscan"
```

## ๐Ÿงช Testing

Run tests for specific modules:

```bash
# Test script engine
cargo test --features "script_engine"

# Test built-in instructions
cargo test --features "scripts_builtin"

# Test memory operations
cargo test --features "memory"
```

## ๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

## ๐Ÿ™ Acknowledgments

- Windows API bindings by [microsoft/windows-rs]https://github.com/microsoft/windows-rs
- Template matching algorithms from [image-rs/imageproc]https://github.com/image-rs/imageproc
- Community feedback and testing

---

**Language**: [English]README.md | [ไธญๆ–‡]docs/zh/README.md