中文 | English
API Reference
Wingman's scripting SDK treats Lua as a first-class citizen (enabled by default, tested along with the main build and CI) and offers Python as an optional backend (embedded CPython + pybind11, off by default, must be enabled explicitly via WINGMAN_ENABLE_PYTHON=ON). Both share the same set of module functionality and the IScriptEngine abstraction.
Why Two Languages
Wingman supports both Python and Lua in order to serve different users' needs:
Python
Suitable for:
- Developers with programming experience
- Automation tasks that involve complex logic
- Work that needs third-party libraries (network requests, data processing, etc.)
- Users who value development efficiency and code maintainability
Strengths:
- Third-party libraries install directly via pip
- Type friendly: supports type hints with solid IDE autocompletion
- Easy debugging: mature debugging tools and error tracing
- Code organization: full object-oriented features including modules, classes, and functions
Typical scenarios:
- Complex game assistance tools (needing network sync, database storage)
- Work that calls AI/vision capabilities (OCR, ONNX model loading, etc.)
- Large automation projects developed by teams
Lua
Suitable for:
- Gamers or light-programming users
- Situations that call for quick, simple scripts
- Resource-constrained environments (embedded, low-spec devices)
- Users who care about startup speed and memory footprint
Strengths:
- Lightweight: small interpreter (< 1MB), fast startup
- Easy to learn: concise syntax, quick to pick up
- Easy deployment: single-file scripts, no dependency management
- Game industry: many games' macro systems use Lua, so users may already know it
Typical scenarios:
- Simple AFK-farming scripts
- Minor tweaks to recorded in-game macros
- Quickly testing automation ideas
SDK Design Philosophy
Naming Conventions
Both languages follow their respective communities' best practices:
Python (snake_case):
screen.get_pixel(x, y)
screen.find_image(path, region)
uia.find_button("确定")
http.post(url, data)Lua (camelCase):
screen.getPixel(x, y)
screen.findImage(path, region)
uia.find_button("确定")
http.post(url, data)Note: Each module's actually registered names are authoritative. Modules such as
screen/input/windoware registered with camelCase names, and the Python binding layer automatically provides snake_case aliases; theuiamodule's registered names are themselves snake_case (same names in both languages, no camelCase forms on the Python side).
Modular Design
All functionality is divided into modules, clear and well-defined:
| Module | Function | Typical use |
|---|---|---|
screen | Screen operations | Screenshots, image finding, pixel sampling |
input | Input simulation | Mouse clicks, keyboard input |
window | Window management | Finding windows, activating windows |
process | Process management | Launching games, checking processes |
uia | UI Automation | Reliable control manipulation |
http | Network requests | API calls, data syncing |
kv | Data storage | Persisting script state |
Consistency Principle
The two languages' APIs are fully equivalent in functionality; only the syntax adapts to each language's conventions:
Same functionality, different syntax:
# Python
from wingman import screen
img = screen.capture()
result = screen.find_image("button.png", {"x": 0, "y": 0, "width": 1920, "height": 1080})
# result 为数组 [point, found](point 为 {x, y} 对象)local wingman = require("wingman")
-- Lua
local img = wingman.screen.capture()
local result = wingman.screen.findImage("button.png", {x = 0, y = 0, width = 1920, height = 1080})
-- result 为数组 {point, found}(point 为 {x, y} 对象)Design Trade-offs
Why Not JavaScript / TypeScript
- Execution efficiency: the V8 engine is large and slow to start
- Deployment complexity: requires a Node.js environment, a high barrier for ordinary users
- Game conflicts: many games embed JS engines in their browser components, which may conflict
Why Not C# / .NET
- Runtime dependency: needs the .NET Runtime, unfriendly to deploy
- Compilation step: users would have to compile, which clashes with scripts' rapid iteration
- Learning curve: too heavy for light users
Python vs Lua Performance
How the two languages behave in practice:
Python strengths:
- Rich third-party library support (numpy, pandas, requests, etc.)
- Mature development tools and debuggers
- Type hints and IDE autocompletion
- Suited to complex logic and large-scale projects
Lua strengths:
- Small interpreter, fast startup
- Relatively low memory footprint
- Concise syntax, small script files
- Easy deployment, no extra dependencies
Recommendations:
- Simple scripts, quick prototypes → Lua
- Complex projects, third-party libraries needed → Python
Quick Start
Python
from wingman import screen, input
# 截屏(返回是否成功,图像存于内部缓冲区)
ok = screen.capture()
# 全屏找图(region 表;返回数组 [point, found])
result = screen.find_image("button.png", {"x": 0, "y": 0, "width": 1920, "height": 1080})
if result[1]:
point = result[0]
input.click(point["x"], point["y"])Lua
local wingman = require("wingman")
-- 截屏(返回是否成功,图像存于内部缓冲区)
local ok = wingman.screen.capture()
-- 全屏找图(region 表;返回数组 {point, found})
local result = wingman.screen.findImage("button.png", {x = 0, y = 0, width = 1920, height = 1080})
if result[2] then
wingman.input.click(result[1].x, result[1].y)
endData Types
See the Data Types reference for the various objects and data structures used in the API.
API Modules
Core Modules
Foundational operation modules providing core functionality such as screen, input, window, and process.
- screen - Screen capture, pixel lookup, image matching
- input - Mouse clicks, movement, keyboard input
- window - Finding, activating, and inspecting windows
- process - Starting, finding, and terminating processes
- system - Getting system information
- uia - UI Automation control interaction
Vision and AI
Computer vision and AI-related functionality.
- vision - Color detection, edge detection, contour recognition
- ocr - Text recognition (OCR, optional dependency)
- ml - ONNX model loading and input/output metadata queries (optional dependency)
Automation Systems
Advanced automation orchestration.
- event - Event subscribe/publish system
- fsm - Finite state machine (FSM)
- task - Task orchestration and execution
- script - Script management control plane (listing, start/stop/reload, environment variables)
- notify - Notification system (logging, Toast, Webhook, tray intents)
- smarttrigger - Smart triggers
- bt - Behavior tree engine
- hotkey - Global hotkey listening (polling-based, Python callbacks)
- systemwatch - System event source: process/window change observation (polling-based, Python callbacks)
Networking
Network requests and communication.
Serialization
Data serialization and format conversion.
- serialize - Serialization format overview (json, yaml, ini selection guide)
- json - JSON parsing and serialization
- ini - INI configuration file parsing and encoding
Data Storage
Local data persistence and caching.
- data - Data storage overview (kv vs db selection guide)
- kv - Persistent key-value store (Redis-like API)
- db - Local SQLite database (SQL and ORM supported)
Utilities
Tool modules that assist automation scripts.
- human - Human-like simulation (random delays, irregular input)
- perf - Performance monitoring
- config - Configuration management
- verification - CAPTCHA recognition, TOTP
- gameprofile - Game configuration profiles
- debugger - Debugger
- util - Utility functions (sleep, random numbers, etc.)
- timer - Timer (one-shot/periodic callbacks, sleep)
- file - File IO (read/write, move/copy, directory operations)
Security and Encryption
Security- and encryption-related functionality.
- security - Security module
- crypto - Cryptographic functions
- clipboard - Clipboard read/write
- macro - Macro recording and playback
- filewatcher - File system watching
Orchestration and Collaboration
Multi-instance collaboration and orchestration.
- orchestration - Orchestration control
- inbox - Message inbox
- team - Team orchestration
- node - Node status and heartbeat (documented in the "Node module (node)" section of the configuration system)
- script - Script management control plane