中文 | English
API Reference
Wingman provides a rich set of APIs to support game automation development.
Table of Contents
Core APIs
The core APIs provide fundamental capabilities such as screen operations, input simulation, and window management.
Module List
| Module | Functionality | Documentation |
|---|---|---|
screen | Screen capture, color detection, image recognition | screen |
input | Mouse clicks, keyboard input, text input | input |
window | Window lookup, activation, bounds retrieval | window |
process | Process lookup and management | process |
vision | Image recognition and matching | vision |
ocr | OCR text recognition | ocr |
smarttrigger | Smart trigger system | smart-trigger |
human | Humanized simulation | human |
perf | Performance monitoring | perf |
system | System information retrieval | system |
uia | UI Automation control interaction | uia |
bt | Behavior tree engine | behavior-tree |
security | Security module | security |
crypto | Cryptographic functions | crypto |
verification | CAPTCHA recognition, TOTP | verification |
gameprofile | Game profiles | gameprofile |
util | Utility functions | util |
ml | ONNX model loading and input/output metadata queries (optional dependency) | ml |
file | File IO (read/write, move/copy, directory operations) | file |
filewatcher | Filesystem watching | filewatcher |
clipboard | Clipboard read/write | clipboard |
hotkey | Global hotkey listening | hotkey |
systemwatch | System event sources (process/window changes) | systemwatch |
Quick Examples
Lua
local wingman = require("wingman")
-- 截图(返回是否成功,图像存于内部缓冲区)
local ok = wingman.screen.capture()
if not ok then
print("截屏失败")
end
-- 查找颜色(返回 {point, found},region 可选)
local result = wingman.screen.findColor(0xFF0000, {x=0, y=0, width=1920, height=1080}, 10)
if result.found then
wingman.input.click(result.point.x, result.point.y)
end
-- 查找图像(返回 {point, found},threshold 可选,默认 0.9)
local match = wingman.screen.findImage("target.png", {x=0, y=0, width=1920, height=1080}, 0.8)
if match.found then
wingman.input.move(match.point.x, match.point.y, 500)
wingman.input.click(match.point.x, match.point.y)
endPython
from wingman import screen, input
# 截图(返回是否成功,图像存于内部缓冲区)
ok = screen.capture()
if not ok:
print("截屏失败")
# 查找颜色(返回 {point, found},region 可选)
result = screen.findColor(0xFF0000, {"x": 0, "y": 0, "width": 1920, "height": 1080}, 10)
if result["found"]:
input.click(result["point"]["x"], result["point"]["y"])
# 查找图像(返回 {point, found},threshold 可选,默认 0.9)
match = screen.findImage("target.png", {"x": 0, "y": 0, "width": 1920, "height": 1080}, 0.8)
if match["found"]:
input.move(match["point"]["x"], match["point"]["y"], 500)
input.click(match["point"]["x"], match["point"]["y"])Data Persistence APIs
The data persistence APIs provide key-value storage and database support.
Module List
| Module | Functionality | Documentation |
|---|---|---|
kv | Key-value storage | kv |
db | SQLite database | db |
Quick Examples
Lua
local wingman = require("wingman")
-- 键值存储
wingman.kv.set("username", "player1")
local name = wingman.kv.get("username")
-- 数据库操作
local conn = wingman.db.open("game_data")
wingman.db.execute(conn, "CREATE TABLE players (id INTEGER PRIMARY KEY, name TEXT)")
wingman.db.execute(conn, "INSERT INTO players (name) VALUES (?)", {"player1"})
local rows = wingman.db.query(conn, "SELECT * FROM players")Python
from wingman import kv, db
# 键值存储
kv.set("username", "player1")
name = kv.get("username")
# 数据库操作
conn = db.open("game_data")
db.execute(conn, "CREATE TABLE players (id INTEGER PRIMARY KEY, name TEXT)")
db.execute(conn, "INSERT INTO players (name) VALUES (?)", ["player1"])
rows = db.query(conn, "SELECT * FROM players")Serialization APIs
The serialization APIs provide support for multiple data formats.
Module List
| Module | Functionality | Documentation |
|---|---|---|
json | JSON encoding/decoding | json |
ini | INI configuration file parsing | ini |
Quick Examples
Lua
local wingman = require("wingman")
-- JSON
local data = {name = "player1", level = 10}
local json_string = wingman.json.encode(data)
local decoded = wingman.json.decode(json_string)
-- INI
local config = wingman.ini.decode(ini_content)
local config_string = wingman.ini.encode(config)Python
from wingman import json, ini
# JSON
data = {"name": "player1", "level": 10}
json_string = json.encode(data)
decoded = json.decode(json_string)
# INI
config = ini.decode(ini_content)
config_string = ini.encode(config)Scripting APIs
The scripting APIs provide script execution and management functionality.
Module List
| Module | Functionality | Documentation |
|---|---|---|
event | Event system | event |
task | Task management | task |
notify | Notification system | notify |
fsm | Finite state machine | fsm |
http | HTTP requests | http |
config | Configuration management | config |
transport | TCP/UDP networking | transport |
script | Script management control plane (listing, start/stop/reload) | script |
timer | Timers (one-shot/periodic callbacks) | timer |
macro | Macro recording and playback | macro |
orchestration | Orchestration control | orchestration |
inbox | Message inbox | inbox |
team | Team orchestration | team |
node | Node management | node |
Debugging APIs
The debugging APIs provide script debugging functionality.
Module List
| Module | Functionality | Documentation |
|---|---|---|
debugger | EmmyLua debugger | debugger |
Quick Examples
Lua
local wingman = require("wingman")
-- 启动调试器
wingman.debugger.start()
-- 在当前位置设置断点
wingman.debugger.breakHere()Find APIs by Feature
Screen and Image
- [Screenshot:
screen.capture(),screen.captureRegion()] - [Color detection:
screen.findColor(),screen.findColors()] - [Image recognition:
screen.findImage()] - [OCR:
ocr.recognize()]
Input and Control
- [Mouse:
input.click(),input.move(),input.scroll()] - Keyboard:
input.keyDown(),input.keyUp(),input.key() - [Text:
input.type()] - [Humanized:
human.mouse_move(),human.mouse_click(),human.keyboard_type()]
Window and Process
- [Window:
window.find(),window.activate(),window.getBounds()] - [Process:
process.find(),process.exists()]
Data and Configuration
- [Storage:
kv.set(),kv.get(),db.open()] - [Configuration:
json.encode(),json.decode(),ini.encode(),ini.decode()]
Automation
- [Triggers:
smarttrigger.create(),smarttrigger.start()] - [Recording:
macro.start(),macro.stop(),macro.playback()] - [Events:
event.on(),event.emit()] - [Tasks:
task.submit(),task.status()]
Networking
- [HTTP:
http.get(),http.post()]
Debugging
- [Debugger:
debugger.start(),debugger.breakpoint(),debugger.breakHere()]
API Naming Conventions
Lua
- Unified import:
local wingman = require("wingman"), with modules accessed as sub-tables:wingman.screen - Method names follow what each module actually registers (e.g.
wingman.screen.capture(),wingman.uia.find_button()) - No constants are currently registered at the script layer
Python
- Module names are lowercase:
from wingman import screen - Method names follow what each module actually registers (camelCase registered names also provide snake_case aliases; natively snake_case registered names exist in that one form only)
[Naming convention: The Python binding layer automatically provides snake_case aliases for camelCase registered names (e.g. the
utilmodule'sgetTimecan be written asget_time); natively snake_case registered names (e.g. theuiamodule'sfind_by_name) exist in that one form only, with no camelCase variant. It is recommended to check each module's documentation first to confirm registered names.]
Type Conversion
Lua to ScriptValue
| Lua Type | ScriptValue Type |
|---|---|
nil | Null |
boolean | Boolean |
number | Integer/Float |
string | String |
table | Object/Array |
function | Function |
Python to ScriptValue
| Python Type | ScriptValue Type |
|---|---|
None | Null |
bool | Boolean |
int | Integer |
float | Float |
str | String |
dict | Object |
list | Array |
function | Function |
Error Handling
Lua
local ok, result = pcall(function()
return wingman.screen.capture()
end)
if not ok then
print("Error:", result)
else
-- result 为布尔值,表示是否截屏成功
endPython
try:
ok = screen.capture()
except Exception as e:
print(f"Error: {e}")Related Documentation
Back: Documentation Home