Documentation ¶
Index ¶
- Constants
- func SetDebugMode(enabled bool) bool
- func SetLogDir(path string) bool
- func SetRecording(enabled bool) bool
- func SetSaveDraw(enabled bool) bool
- func SetShowHitDraw(enabled bool) bool
- func SetStdoutLevel(level LoggingLevel) bool
- func Version() string
- type AdbDevice
- type AdbInputMethod
- type AdbScreencapMethod
- type Context
- func (ctx *Context) Clone() *Context
- func (ctx *Context) GetTaskJob() *TaskJob
- func (ctx *Context) GetTasker() *Tasker
- func (ctx *Context) OverrideNext(name string, nextList []string) bool
- func (ctx *Context) OverridePipeline(override any) bool
- func (ctx *Context) RunAction(entry string, box Rect, recognitionDetail string, override ...any) *NodeDetail
- func (ctx *Context) RunPipeline(entry string, override ...any) *TaskDetail
- func (ctx *Context) RunRecognition(entry string, img image.Image, override ...any) *RecognitionDetail
- type Controller
- func NewAdbController(adbPath, address string, screencapMethod AdbScreencapMethod, ...) Controller
- func NewCustomController(ctrl CustomController, notify Notification) Controller
- func NewDbgController(readPath, writePath string, dbgCtrlType DbgControllerType, config string, ...) Controller
- func NewWin32Controller(hWnd unsafe.Pointer, screencapMethod Win32ScreencapMethod, ...) Controller
- type ControllerActionDetail
- type CustomAction
- type CustomActionArg
- type CustomController
- type CustomControllerHandler
- type CustomRecognition
- type CustomRecognitionArg
- type CustomRecognitionResult
- type DbgControllerType
- type DesktopWindow
- type InterenceDevice
- type J
- type Job
- type LoggingLevel
- type NodeDetail
- type Notification
- type NotificationType
- type RecognitionDetail
- type Rect
- type Resource
- func (r *Resource) Clear() bool
- func (r *Resource) ClearCustomAction() bool
- func (r *Resource) ClearCustomRecognition() bool
- func (r *Resource) Destroy()
- func (r *Resource) GetHash() (string, bool)
- func (r *Resource) GetTaskList() ([]string, bool)
- func (r *Resource) Loaded() bool
- func (r *Resource) PostPath(path string) *Job
- func (r *Resource) RegisterCustomAction(name string, action CustomAction) bool
- func (r *Resource) RegisterCustomRecognition(name string, recognition CustomRecognition) bool
- func (r *Resource) UnregisterCustomAction(name string) bool
- func (r *Resource) UnregisterCustomRecognition(name string) bool
- func (r *Resource) UseAutoExecutionProvider() bool
- func (r *Resource) UseCPU() bool
- func (r *Resource) UseCoreml(coremlFlag InterenceDevice) bool
- func (r *Resource) UseDirectml(deviceID InterenceDevice) bool
- type ResourceLoadingDetail
- type Status
- type TaskActionDetail
- type TaskDetail
- type TaskJob
- type TaskNextListDetail
- type TaskRecognitionDetail
- type Tasker
- func (t *Tasker) BindController(ctrl Controller) bool
- func (t *Tasker) BindResource(res *Resource) bool
- func (t *Tasker) ClearCache() bool
- func (t *Tasker) Destroy()
- func (t *Tasker) GetController() Controller
- func (t *Tasker) GetLatestNode(taskName string) *NodeDetail
- func (t *Tasker) GetResource() *Resource
- func (t *Tasker) Initialized() bool
- func (t *Tasker) PostPipeline(entry string, override ...any) *TaskJob
- func (t *Tasker) PostStop() *TaskJob
- func (t *Tasker) Running() bool
- type TaskerTaskDetail
- type Toolkit
- func (t *Toolkit) ClearPICustom(instId uint64)
- func (t *Toolkit) ConfigInitOption(userPath, defaultJson string) bool
- func (t *Toolkit) FindAdbDevices(specifiedAdb ...string) []*AdbDevice
- func (t *Toolkit) FindDesktopWindows() []*DesktopWindow
- func (t *Toolkit) RegisterPICustomAction(instId uint64, name string, action CustomAction)
- func (t *Toolkit) RegisterPICustomRecognition(instId uint64, name string, recognition CustomRecognition)
- func (t *Toolkit) RunCli(instId uint64, resourcePath, userPath string, directly bool, ...) bool
- type Win32InputMethod
- type Win32ScreencapMethod
Constants ¶
const ( InterenceDeviceAuto int32 = -1 InferenceDevice0 int32 = 0 InferenceDevice1 int32 = 1 )
Variables ¶
This section is empty.
Functions ¶
func SetDebugMode ¶ added in v1.1.0
SetDebugMode sets whether to enable debug mode.
func SetRecording ¶
SetRecording sets whether to dump all screenshots and actions.
func SetShowHitDraw ¶
SetShowHitDraw sets whether to show hit draw.
func SetStdoutLevel ¶
func SetStdoutLevel(level LoggingLevel) bool
SetStdoutLevel sets the level of log output to stdout.
Types ¶
type AdbDevice ¶ added in v1.0.1
type AdbDevice struct { Name string AdbPath string Address string ScreencapMethod AdbScreencapMethod InputMethod AdbInputMethod Config string }
AdbDevice represents a single ADB device with various properties about its information.
type AdbInputMethod ¶ added in v1.0.0
type AdbInputMethod uint64
AdbInputMethod
Use bitwise OR to set the method you need, MaaFramework will select the available ones according to priority. The priority is: EmulatorExtras > Maatouch > MinitouchAndAdbKey > AdbShell
const ( AdbInputMethodNone AdbInputMethod = 0 AdbInputMethodAdbShell AdbInputMethod = 1 AdbInputMethodMinitouchAndAdbKey AdbInputMethod = 1 << 1 AdbInputMethodMaatouch AdbInputMethod = 1 << 2 AdbInputMethodEmulatorExtras AdbInputMethod = 1 << 3 AdbInputMethodAll = ^AdbInputMethodNone AdbInputMethodDefault = AdbInputMethodAll & (^AdbInputMethodEmulatorExtras) )
AdbInputMethod
type AdbScreencapMethod ¶ added in v1.0.0
type AdbScreencapMethod uint64
AdbScreencapMethod
Use bitwise OR to set the method you need, MaaFramework will test their speed and use the fastest one.
const ( AdbScreencapMethodNone AdbScreencapMethod = 0 AdbScreencapMethodEncodeToFileAndPull AdbScreencapMethod = 1 AdbScreencapMethodEncode AdbScreencapMethod = 1 << 1 AdbScreencapMethodRawWithGzip AdbScreencapMethod = 1 << 2 AdbScreencapMethodRawByNetcat AdbScreencapMethod = 1 << 3 AdbScreencapMethodMinicapDirect AdbScreencapMethod = 1 << 4 AdbScreencapMethodMinicapStream AdbScreencapMethod = 1 << 5 AdbScreencapMethodEmulatorExtras AdbScreencapMethod = 1 << 6 AdbScreencapMethodAll = ^AdbScreencapMethodNone AdbScreencapMethodDefault = AdbScreencapMethodAll & (^AdbScreencapMethodRawByNetcat) & (^AdbScreencapMethodMinicapDirect) & (^AdbScreencapMethodMinicapStream) )
AdbScreencapMethod
type Context ¶ added in v1.0.0
type Context struct {
// contains filtered or unexported fields
}
func (*Context) GetTaskJob ¶ added in v1.0.0
GetTaskJob returns current task job.
func (*Context) OverrideNext ¶ added in v1.0.0
OverrideNext overrides the next list of task by name.
func (*Context) OverridePipeline ¶ added in v1.0.0
OverridePipeline overrides pipeline. The `override` parameter can be a JSON string or any data type that can be marshaled to JSON.
func (*Context) RunAction ¶ added in v1.0.0
func (ctx *Context) RunAction(entry string, box Rect, recognitionDetail string, override ...any) *NodeDetail
RunAction run an action and return its detail. It accepts an entry string and an optional override parameter which can be a JSON string or any data type that can be marshaled to JSON. If multiple overrides are provided, only the first one will be used.
Example 1:
ctx.RunAction("Task", `{"Task":{"action":"Click","target":[100, 200, 100, 100]}}`)
Example 2:
ctx.RunAction("Task", map[string]interface{}{ "Task": map[string]interface{}{ "action": "Click", "target": []int{100, 200, 100, 100}, } })
func (*Context) RunPipeline ¶ added in v1.0.0
func (ctx *Context) RunPipeline(entry string, override ...any) *TaskDetail
RunPipeline runs a pipeline and returns its detail. It accepts an entry string and an optional override parameter which can be a JSON string or any data type that can be marshaled to JSON. If multiple overrides are provided, only the first one will be used.
Example 1:
ctx.RunPipeline("Task", `{"Task":{"action":"Click","target":[100, 200, 100, 100]}}`)
Example 2:
ctx.RunPipeline("Task", map[string]interface{}{ "Task": map[string]interface{}{ "action": "Click", "target": []int{100, 200, 100, 100}, } })
func (*Context) RunRecognition ¶ added in v1.0.0
func (ctx *Context) RunRecognition(entry string, img image.Image, override ...any) *RecognitionDetail
RunRecognition run a recognition and return its detail. It accepts an entry string and an optional override parameter which can be a JSON string or any data type that can be marshaled to JSON. If multiple overrides are provided, only the first one will be used.
Example 1:
ctx.RunRecognition("Task", `{"Task":{"recognition":"OCR","expected":"Hello"}}`)
Example 2:
ctx.RunRecognition("Task", map[string]interface{}{ "Task": map[string]interface{}{ "recognition": "OCR", "expected": "Hello", } })
type Controller ¶
type Controller interface { Destroy() Handle() uintptr SetScreenshotTargetLongSide(targetLongSide int32) bool SetScreenshotTargetShortSide(targetShortSide int32) bool SetScreenshotUseRawSize(enabled bool) bool SetRecording(enabled bool) bool PostConnect() *Job PostClick(x, y int32) *Job PostSwipe(x1, y1, x2, y2 int32, duration time.Duration) *Job PostPressKey(keycode int32) *Job PostInputText(text string) *Job PostStartApp(intent string) *Job PostStopApp(intent string) *Job PostTouchDown(contact, x, y, pressure int32) *Job PostTouchMove(contact, x, y, pressure int32) *Job PostTouchUp(contact int32) *Job PostScreencap() *Job Connected() bool CacheImage() image.Image GetUUID() (string, bool) }
Controller is an interface that defines various methods for MAA controller.
func NewAdbController ¶
func NewAdbController( adbPath, address string, screencapMethod AdbScreencapMethod, inputMethod AdbInputMethod, config, agentPath string, notify Notification, ) Controller
NewAdbController creates an ADB controller instance.
func NewCustomController ¶
func NewCustomController( ctrl CustomController, notify Notification, ) Controller
NewCustomController creates a custom controller instance.
func NewDbgController ¶
func NewDbgController( readPath, writePath string, dbgCtrlType DbgControllerType, config string, notify Notification, ) Controller
NewDbgController creates a DBG controller instance.
func NewWin32Controller ¶
func NewWin32Controller( hWnd unsafe.Pointer, screencapMethod Win32ScreencapMethod, inputMethod Win32InputMethod, notify Notification, ) Controller
NewWin32Controller creates a win32 controller instance.
type ControllerActionDetail ¶ added in v1.1.0
type CustomAction ¶
type CustomAction interface {
Run(ctx *Context, arg *CustomActionArg) bool
}
type CustomActionArg ¶ added in v1.0.1
type CustomActionArg struct { TaskDetail *TaskDetail CurrentTaskName string CustomActionName string CustomActionParam string RecognitionDetail *RecognitionDetail Box Rect }
type CustomController ¶
type CustomController interface { Connect() bool RequestUUID() (string, bool) StartApp(intent string) bool StopApp(intent string) bool Screencap() (image.Image, bool) Click(x, y int32) bool Swipe(x1, y1, x2, y2, duration int32) bool TouchDown(contact, x, y, pressure int32) bool TouchMove(contact, x, y, pressure int32) bool TouchUp(contact int32) bool PressKey(keycode int32) bool InputText(text string) bool Handle() uintptr }
CustomController defines an interface for custom controller. Implementers of this interface must embed a CustomControllerHandler struct and provide implementations for the following methods: Connect, RequestUUID, StartApp, StopApp, Screencap, Click, Swipe, TouchDown, TouchMove, TouchUp, PressKey and InputText.
type CustomControllerHandler ¶ added in v0.2.0
type CustomControllerHandler struct {
// contains filtered or unexported fields
}
func NewCustomControllerHandler ¶ added in v0.2.0
func NewCustomControllerHandler() CustomControllerHandler
func (CustomControllerHandler) Handle ¶ added in v0.2.0
func (c CustomControllerHandler) Handle() uintptr
type CustomRecognition ¶ added in v1.1.0
type CustomRecognition interface {
Run(ctx *Context, arg *CustomRecognitionArg) (*CustomRecognitionResult, bool)
}
type CustomRecognitionArg ¶ added in v1.1.0
type CustomRecognitionResult ¶ added in v1.1.0
type DbgControllerType ¶
type DbgControllerType uint64
DbgControllerType
No bitwise OR, just set it.
const ( DbgControllerTypeNone DbgControllerType = 0 DbgControllerTypeCarouselImage DbgControllerType = 1 DbgControllerTypeReplayRecording DbgControllerType = 1 << 1 )
DbgControllerType
type DesktopWindow ¶ added in v1.0.1
DesktopWindow represents a single desktop window with various properties about its information.
type InterenceDevice ¶ added in v1.7.0
type InterenceDevice = maa.MaaInferenceDevice
type Job ¶ added in v0.4.0
type Job struct {
// contains filtered or unexported fields
}
type LoggingLevel ¶
type LoggingLevel int32
const ( LoggingLevelOff LoggingLevel = iota LoggingLevelFatal LoggingLevelError LoggingLevelWarn LoggingLevelInfo LoggingLevelDebug LoggingLevelTrace LoggingLevelAll )
LoggingLevel
type NodeDetail ¶
type NodeDetail struct { ID int64 Name string Recognition *RecognitionDetail RunCompleted bool }
type Notification ¶ added in v1.1.0
type Notification interface { OnResourceLoading(notifyType NotificationType, detail ResourceLoadingDetail) OnControllerAction(notifyType NotificationType, detail ControllerActionDetail) OnTaskerTask(notifyType NotificationType, detail TaskerTaskDetail) OnTaskNextList(notifyType NotificationType, detail TaskNextListDetail) OnTaskRecognition(notifyType NotificationType, detail TaskRecognitionDetail) OnTaskAction(notifyType NotificationType, detail TaskActionDetail) OnUnknownNotification(msg, detailsJSON string) }
type NotificationType ¶ added in v1.1.0
type NotificationType int
const ( NotificationTypeUnknown NotificationType = iota NotificationTypeStarting NotificationTypeSucceeded NotificationTypeFailed )
NotificationType
type RecognitionDetail ¶
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
func NewResource ¶
func NewResource(notify Notification) *Resource
NewResource creates a new resource.
func (*Resource) ClearCustomAction ¶ added in v1.0.0
ClearCustomAction clears all custom actions registered from the resource.
func (*Resource) ClearCustomRecognition ¶ added in v1.1.0
ClearCustomRecognition clears all custom recognitions registered from the resource.
func (*Resource) GetTaskList ¶
GetTaskList returns the task list of the resource.
func (*Resource) PostPath ¶
PostPath adds a path to the resource loading paths. Return id of the resource.
func (*Resource) RegisterCustomAction ¶ added in v1.0.0
func (r *Resource) RegisterCustomAction(name string, action CustomAction) bool
RegisterCustomAction registers a custom action to the resource.
func (*Resource) RegisterCustomRecognition ¶ added in v1.1.0
func (r *Resource) RegisterCustomRecognition(name string, recognition CustomRecognition) bool
RegisterCustomRecognition registers a custom recognition to the resource.
func (*Resource) UnregisterCustomAction ¶ added in v1.0.0
UnregisterCustomAction unregisters a custom action from the resource.
func (*Resource) UnregisterCustomRecognition ¶ added in v1.1.0
UnregisterCustomRecognition unregisters a custom recognition from the resource.
func (*Resource) UseAutoExecutionProvider ¶ added in v1.7.0
UseAutoExecutionProvider
func (*Resource) UseCoreml ¶ added in v1.7.0
func (r *Resource) UseCoreml(coremlFlag InterenceDevice) bool
UseCoreml
func (*Resource) UseDirectml ¶ added in v1.7.0
func (r *Resource) UseDirectml(deviceID InterenceDevice) bool
UseDirectml
type ResourceLoadingDetail ¶ added in v1.1.0
type TaskActionDetail ¶ added in v1.1.0
type TaskDetail ¶
type TaskDetail struct { ID int64 Entry string NodeDetails []*NodeDetail Status Status }
type TaskJob ¶ added in v0.4.0
type TaskJob struct { *Job // contains filtered or unexported fields }
func NewTaskJob ¶ added in v0.4.0
func (*TaskJob) GetDetail ¶ added in v0.4.0
func (j *TaskJob) GetDetail() *TaskDetail
type TaskNextListDetail ¶ added in v1.1.0
type TaskRecognitionDetail ¶ added in v1.1.0
type Tasker ¶ added in v1.0.0
type Tasker struct {
// contains filtered or unexported fields
}
func NewTasker ¶ added in v1.0.0
func NewTasker(notify Notification) *Tasker
NewTasker creates an new tasker.
func (*Tasker) BindController ¶ added in v1.0.0
func (t *Tasker) BindController(ctrl Controller) bool
BindController binds the tasker to an initialized controller.
func (*Tasker) BindResource ¶ added in v1.0.0
BindResource binds the tasker to an initialized resource.
func (*Tasker) ClearCache ¶ added in v1.0.0
ClearCache clears runtime cache.
func (*Tasker) GetController ¶ added in v1.0.0
func (t *Tasker) GetController() Controller
GetController returns the controller handle of the tasker.
func (*Tasker) GetLatestNode ¶ added in v1.0.0
func (t *Tasker) GetLatestNode(taskName string) *NodeDetail
GetLatestNode returns latest node id.
func (*Tasker) GetResource ¶ added in v1.0.0
GetResource returns the resource handle of the tasker.
func (*Tasker) Initialized ¶ added in v1.1.0
Initialized checks if the tasker is initialized.
func (*Tasker) PostPipeline ¶ added in v1.0.0
PostPipeline posts a task to the tasker. `override` is an optional parameter. If provided, it should be a single value that can be a JSON string or any data type that can be marshaled to JSON. If multiple values are provided, only the first one will be used.
type TaskerTaskDetail ¶ added in v1.1.0
type Toolkit ¶ added in v1.0.1
type Toolkit struct{}
func NewToolkit ¶ added in v1.0.1
func NewToolkit() *Toolkit
NewToolkit creates a new toolkit instance.
func (*Toolkit) ClearPICustom ¶ added in v1.0.1
ClearPICustom unregisters all custom recognitions and actions for a given instance.
func (*Toolkit) ConfigInitOption ¶ added in v1.0.1
ConfigInitOption inits the toolkit config option.
func (*Toolkit) FindAdbDevices ¶ added in v1.0.1
FindAdbDevices finds adb devices.
func (*Toolkit) FindDesktopWindows ¶ added in v1.0.1
func (t *Toolkit) FindDesktopWindows() []*DesktopWindow
FindDesktopWindows finds desktop windows.
func (*Toolkit) RegisterPICustomAction ¶ added in v1.0.1
func (t *Toolkit) RegisterPICustomAction(instId uint64, name string, action CustomAction)
RegisterPICustomAction registers a custom action.
func (*Toolkit) RegisterPICustomRecognition ¶ added in v1.1.0
func (t *Toolkit) RegisterPICustomRecognition(instId uint64, name string, recognition CustomRecognition)
RegisterPICustomRecognition registers a custom recognizer.
type Win32InputMethod ¶ added in v1.0.0
type Win32InputMethod uint64
Win32InputMethod
No bitwise OR, just set it.
const ( Win32InputMethodNone Win32InputMethod = 0 Win32InputMethodSeize Win32InputMethod = 1 Win32InputMethodSendMessage Win32InputMethod = 1 << 1 )
Win32InputMethod
type Win32ScreencapMethod ¶ added in v1.0.0
type Win32ScreencapMethod uint64
Win32ScreencapMethod
No bitwise OR, just set it.
const ( Win32ScreencapMethodNone Win32ScreencapMethod = 0 Win32ScreencapMethodGDI Win32ScreencapMethod = 1 Win32ScreencapMethodFramePool Win32ScreencapMethod = 1 << 1 Win32ScreencapMethodDXGIDesktopDup Win32ScreencapMethod = 1 << 2 )
Win32ScreencapMethod