ไธญๆๆๆกฃ | English Documentation
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.
- 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
โ
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
Add to your Cargo.toml:
[dependencies]
win-auto-utils = { version = "0.2.6", features = ["standard"] }For full functionality including template matching:
[dependencies]
win-auto-utils = { version = "0.2.6", features = ["full"] }Only three types needed for full functionality!
use win_auto_utils::process::{Process, ProcessConfig, ProcessManager};
// Method 1: One-step initialization by name (most convenient)
let mut process = Process::init_by_name("notepad.exe")?;
println!("PID: {}", process.pid_or_default());
// Method 2: One-step initialization by PID (when you know the PID)
let process = Process::init_by_pid(12345)?;
println!("HWND: {:?}", process.hwnd_or_default());
// Method 3: Using Builder with intuitive methods (no enums needed!)
let config = ProcessConfig::builder("target.exe")
.set_window_client_mode() // Easy to remember - no DCMode enum!
.exclude_invisible()
.include_by_title("Game Window")
.build();
let mut game = Process::new(config);
game.init()?;
// Method 4: Instance method init_with_pid (for existing Process objects)
// Useful for distinguishing multiple instances of the same process
let mut app = Process::by_name("target.exe");
app.init()?; // Initialize first instance
// Later, switch to specific PID for second instance
app.init_with_pid(20908)?;
// Manager API (simple and straightforward):
let mut manager = ProcessManager::new();
manager.register("notepad.exe")?; // process name becomes the key
manager.register_alias("game", "target.exe")?; // custom alias
manager.init("notepad.exe")?;
manager.init_with_pid("game", 12345)?; // initialize with specific PID
// Query processes (read-only, no mut needed)
if let Some(proc) = manager.get("notepad.exe") {
println!("PID: {:?}", proc.pid());
}
// DC Mode Options (intuitive method names):
// - .set_window_mode() -> Standard window DC (GetWindowDC)
// - .set_window_client_mode() -> Client area DC (GetDC) - best for games
// - .set_desktop_mode() -> Desktop DC for full-screen captureuse 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)?;use win_auto_utils::keyboard::{SendInputKeyboard, PostMessageKeyboard};
use win_auto_utils::mouse::{SendInputMouse, PostMessageMouse};
// SendInput method (system-level input, works with all apps)
let mut kb = SendInputKeyboard::new();
kb.click("a")?;
let mut mouse = SendInputMouse::new();
mouse.move_to(100, 200)?;
mouse.click_left()?;
// PostMessage method (background input, no focus required, needs HWND)
let kb = PostMessageKeyboard::new(hwnd);
kb.click("a")?;
let mouse = PostMessageMouse::new(hwnd);
mouse.move_to(100, 200)?;
mouse.click_left_at(100, 200)?;use win_auto_utils::dxgi::DxgiCapture;
let mut capture = DxgiCapture::new()?;
let image = capture.capture_window(hwnd)?;Search for colors in screen regions or pixel buffers with automatic AVX2 optimization:
use win_auto_utils::color_finder::{find_color, find_color_in_buffer};
// Method 1: Find color in screen region (uses DXGI capture internally)
match find_color(100, 100, 50, 50, (255, 0, 0)) { // Search red in 50x50 region
Ok(result) => {
if result.matched {
println!("Found at screen coordinates ({}, {})", result.x, result.y);
}
}
Err(e) => eprintln!("Error: {}", e),
}
// Method 2: Find color in pixel buffer (pure algorithm, no screen capture)
use win_auto_utils::color_finder::algorithms::find_color_in_buffer;
let buffer: Vec<u8> = vec![0; 100 * 100 * 4]; // 100x100 BGRA pixels
let result = find_color_in_buffer(&buffer, 100, 100, (0, 255, 0)); // Search greenFeatures:
- AVX2 SIMD acceleration (~4-8x faster on supported hardware)
- Automatic fallback to scalar implementation
- Works with any BGRA pixel buffer source
use win_auto_utils::memory_manager::ModifierManager;
use win_auto_utils::memory_manager::builtin::TrampolineHookHandler;
use win_auto_utils::process::ProcessManager;
// Initialize process
let mut process_mgr = ProcessManager::new();
process_mgr.register("target_app.exe")?;
process_mgr.init("target_app.exe")?;
let proc = process_mgr.get("target_app.exe").unwrap();
let handle = proc.handle().unwrap();
let pid = proc.pid().unwrap();
// Create manager and bind context
let mut manager = ModifierManager::new();
manager.set_context(handle, pid);
// Register hook with shellcode (architecture auto-detected)
let shellcode = vec![0x90, 0x90]; // NOP instruction
let hook_handler = TrampolineHookHandler::new_hook_aob_with_offset(
"func_hook",
"48 8B 05 ?? ?? ?? ??", // AOB pattern
shellcode,
2, // bytes_to_overwrite
0x10, // offset
)?;
manager.register("func_hook", hook_handler);
// Activate hook
manager.activate("func_hook")?;
// ... trigger hook ...
// Deactivate (auto-frees memory)
manager.deactivate("func_hook")?;Legacy Direct API (still supported but not recommended):
use win_auto_utils::memory_hook::TrampolineHook;
let shellcode = vec![0x01, 0xD2]; // add edx, edx
let mut hook = TrampolineHook::new_x86(handle, target_addr, shellcode);
hook.install()?;
// ... trigger hook ...
hook.uninstall()?; // Auto-frees memoryuse 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)?;Comprehensive documentation is available in both English and Chinese:
- Documentation Index (EN) - Complete navigation guide
- ๆๆกฃ็ดขๅผ (ไธญๆ) - ๅฎๆดๅฏผ่ชๆๅ
- Modules Overview - High-level view of all modules
- Memory Operations
- Memory Manager - Unified memory modification manager
- Memory Hooking
- Address Resolution
- AOB Scanning
- Script Engine
- Input Control
- Process & Window
- Screen Capture
- Template Matching
- DLL Injection
- ๆจกๅๆฆ่ง - ๆๆๆจกๅ็้ซๅฑ่งๅพ
- ๅ ๅญๆไฝ
- ๅ ๅญ็ฎก็ๅจ - ็ปไธ็ๅ ๅญไฟฎๆน็ฎก็ๅจ
- ๅ ๅญ้ฉๅญ
- ๅฐๅ่งฃๆ
- ๅญ่ๆซๆ
- ่ๆฌๅผๆ
- ่พๅ ฅๆงๅถ
- ่ฟ็จไธ็ชๅฃ
- ๅฑๅนๆ่ท
- ๆจกๆฟๅน้
- DLLๆณจๅ ฅ
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
Choose only what you need:
cargo build --no-default-features --features "keyboard,mouse"cargo build # Includes all stable features except template_matchercargo build --no-default-features --features "full"| Feature | Description | Dependencies |
|---|---|---|
process |
Process management | windows, hwnd, hdc, snapshot, handle |
keyboard |
Keyboard input | windows |
mouse |
Mouse control | windows |
color_picker |
GDI color picking | windows |
color_finder |
Pixel color search (AVX2/SIMD) | dxgi |
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 for complete feature list.
Explore the examples/ directory for usage demonstrations:
# General memory manager usage
cargo run --example memory_manager_example --features "memory_manager"# Process manager example
cargo run --example process_manager_example --features "process"
# Custom initialization flags
cargo run --example custom_init_flags --features "process"
# Window activation instruction
cargo run --example active_instruction --features "scripts_window"# DXGI capture example
cargo run --example dxgi_capture --features "dxgi"
# Performance comparison
cargo run --example dxgi_performance_comparison --features "dxgi"# Script engine with built-in instructions
cargo run --example script_engine --features "script_engine,scripts_builtin"# Color conversion utilities
cargo run --example color_conversion --features "color_picker"
# Color finder re-exports
cargo run --example color_reexports --features "color_finder"# Clipboard usage example
cargo run --example clipboard_usage --features "clipboard"# 64-bit bytecode AOB scanning
cargo run --example aobscan_64bit_bytecode --features "memory_aobscan"# DLL injection example
cargo run --example dll_injection --features "dll_injector"Run tests for specific modules:
# Test script engine
cargo test --features "script_engine"
# Test built-in instructions
cargo test --features "scripts_builtin"
# Test memory operations
cargo test --features "memory"