Skip to content

中文 | 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):

python
screen.get_pixel(x, y)
screen.find_image(path, region)
uia.find_button("确定")
http.post(url, data)

Lua (camelCase):

lua
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/window are registered with camelCase names, and the Python binding layer automatically provides snake_case aliases; the uia module'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:

ModuleFunctionTypical use
screenScreen operationsScreenshots, image finding, pixel sampling
inputInput simulationMouse clicks, keyboard input
windowWindow managementFinding windows, activating windows
processProcess managementLaunching games, checking processes
uiaUI AutomationReliable control manipulation
httpNetwork requestsAPI calls, data syncing
kvData storagePersisting 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
# 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} 对象)
lua
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 ​

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 ​

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)
end

Data 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.

  • http - HTTP client (GET, POST, downloads)
  • transport - TCP client, server, and UDP sockets

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.

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