Documentation
¶
Index ¶
- Constants
- func AgentServerDetach()
- func AgentServerJoin()
- func AgentServerRegisterCustomAction(name string, action CustomAction) bool
- func AgentServerRegisterCustomRecognition(name string, recognition CustomRecognition) bool
- func AgentServerShutDown()
- func AgentServerStartUp(identifier string) bool
- func SetDebugMode(enabled bool) bool
- func SetLogDir(path string) bool
- func SetRecording(enabled bool) bool
- func SetSaveDraw(enabled bool) bool
- func SetStdoutLevel(level LoggingLevel) bool
- func Version() string
- type AdbDevice
- type AdbInputMethod
- type AdbScreencapMethod
- type AgentClient
- type Context
- func (ctx *Context) Clone() *Context
- func (ctx *Context) GetNodeJSON(name string) (bool, string)
- 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) RunRecognition(entry string, img image.Image, override ...any) *RecognitionDetail
- func (ctx *Context) RunTask(entry string, override ...any) *TaskDetail
- 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 NodeActionDetail
- type NodeDetail
- type NodeNextListDetail
- type NodeRecognitionDetail
- 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) GetNodeJSON(name string) (bool, string)
- func (r *Resource) GetNodeList() ([]string, bool)
- func (r *Resource) Loaded() bool
- func (r *Resource) OverrideNext(name string, nextList []string) bool
- func (r *Resource) OverridePipeline(override any) bool
- func (r *Resource) PostBundle(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 TaskDetail
- type TaskJob
- 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) PostStop() *TaskJob
- func (t *Tasker) PostTask(entry string, override ...any) *TaskJob
- func (t *Tasker) Running() bool
- func (t *Tasker) Stopping() 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 ( AdbScreencapMethodEncodeToFileAndPullValue = "EncodeToFileAndPull" AdbScreencapMethodEncodeValue = "Encode" AdbScreencapMethodRawWithGzipValue = "RawWithGzip" AdbScreencapMethodRawByNetcatValue = "RawByNetcat" AdbScreencapMethodMinicapDirectValue = "MinicapDirect" AdbScreencapMethodMinicapStreamValue = "MinicapStream" AdbScreencapMethodEmulatorExtrasValue = "EmulatorExtras" AdbScreencapMethodAllValue = "All" AdbScreencapMethodDefaultValue = "Default" AdbInputMethodAdbShellValue = "AdbShell" AdbInputMethodMinitouchAndAdbKeyValue = "MinitouchAndAdbKey" AdbInputMethodMaatouchValue = "Maatouch" AdbInputMethodEmulatorExtrasValue = "EmulatorExtras" AdbInputMethodAllValue = "All" AdbInputMethodDefaultValue = "Default" Win32ScreencapMethodGDIValue = "GDI" Win32ScreencapMethodFramePoolValue = "FramePool" Win32ScreencapMethodDXGIDesktopDupValue = "DXGIDesktopDup" Win32InputMethodSeizeValue = "Seize" Win32InputMethodSendMessageValue = "SendMessage" DbgControllerTypeCarouselImageValue = "CarouselImage" DbgControllerTypeReplayRecordingValue = "ReplayRecording" )
const ( InterenceDeviceAuto int32 = -1 InferenceDevice0 int32 = 0 InferenceDevice1 int32 = 1 )
Variables ¶
This section is empty.
Functions ¶
func AgentServerDetach ¶ added in v2.2.0
func AgentServerDetach()
func AgentServerJoin ¶ added in v2.2.0
func AgentServerJoin()
func AgentServerRegisterCustomAction ¶ added in v2.2.0
func AgentServerRegisterCustomAction(name string, action CustomAction) bool
func AgentServerRegisterCustomRecognition ¶ added in v2.2.0
func AgentServerRegisterCustomRecognition(name string, recognition CustomRecognition) bool
func AgentServerShutDown ¶ added in v2.2.0
func AgentServerShutDown()
func AgentServerStartUp ¶ added in v2.2.0
func SetDebugMode ¶
SetDebugMode sets whether to enable debug mode.
func SetRecording ¶
SetRecording sets whether to dump all screenshots and actions.
func SetStdoutLevel ¶
func SetStdoutLevel(level LoggingLevel) bool
SetStdoutLevel sets the level of log output to stdout.
Types ¶
type AdbDevice ¶
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 ¶
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
func ParseAdbInputMethod ¶ added in v2.1.0
func ParseAdbInputMethod(methodStr string) (AdbInputMethod, error)
func (AdbInputMethod) String ¶ added in v2.1.0
func (m AdbInputMethod) String() string
type AdbScreencapMethod ¶
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
func ParseAdbScreencapMethod ¶ added in v2.1.0
func ParseAdbScreencapMethod(methodStr string) (AdbScreencapMethod, error)
func (AdbScreencapMethod) String ¶ added in v2.1.0
func (m AdbScreencapMethod) String() string
type AgentClient ¶ added in v2.2.0
type AgentClient struct {
// contains filtered or unexported fields
}
func NewAgentClient ¶ added in v2.2.0
func NewAgentClient() *AgentClient
NewAgentClient creates and initializes a new Agent client instance
func (*AgentClient) BindResource ¶ added in v2.2.0
func (ac *AgentClient) BindResource(res *Resource) bool
BindResource binds a resource object to the client
func (*AgentClient) Connect ¶ added in v2.2.0
func (ac *AgentClient) Connect() bool
Connect attempts to establish connection with Agent service
func (*AgentClient) CreateSocket ¶ added in v2.2.0
func (ac *AgentClient) CreateSocket(identifier string) bool
CreateSocket creates a socket connection with specified identifier
func (*AgentClient) Destroy ¶ added in v2.2.0
func (ac *AgentClient) Destroy()
Destroy releases underlying resources
func (*AgentClient) Disconnect ¶ added in v2.2.0
func (ac *AgentClient) Disconnect() bool
Disconnect actively terminates current connection
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) GetNodeJSON ¶ added in v2.3.0
GetNodeJSON gets the node JSON by name.
func (*Context) GetTaskJob ¶
GetTaskJob returns current task job.
func (*Context) OverrideNext ¶
OverrideNext overrides the next list of task by name.
func (*Context) OverridePipeline ¶
OverridePipeline overrides pipeline. The `override` parameter can be a JSON string or any data type that can be marshaled to JSON.
func (*Context) RunAction ¶
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) RunRecognition ¶
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", } })
func (*Context) RunTask ¶
func (ctx *Context) RunTask(entry string, override ...any) *TaskDetail
RunTask runs a task 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.RunTask("Task", `{"Task":{"action":"Click","target":[100, 200, 100, 100]}}`)
Example 2:
ctx.RunTask("Task", map[string]interface{}{ "Task": map[string]interface{}{ "action": "Click", "target": []int{100, 200, 100, 100}, } })
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 ¶
type CustomAction ¶
type CustomAction interface {
Run(ctx *Context, arg *CustomActionArg) bool
}
type CustomActionArg ¶
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 ¶
type CustomControllerHandler struct {
// contains filtered or unexported fields
}
func NewCustomControllerHandler ¶
func NewCustomControllerHandler() CustomControllerHandler
func (CustomControllerHandler) Handle ¶
func (c CustomControllerHandler) Handle() uintptr
type CustomRecognition ¶
type CustomRecognition interface {
Run(ctx *Context, arg *CustomRecognitionArg) (*CustomRecognitionResult, bool)
}
type CustomRecognitionArg ¶
type CustomRecognitionResult ¶
type DbgControllerType ¶
type DbgControllerType uint64
DbgControllerType
No bitwise OR, just set it.
const ( DbgControllerTypeNone DbgControllerType = 0 DbgControllerTypeCarouselImage DbgControllerType = 1 DbgControllerTypeReplayRecording DbgControllerType = 1 << 1 )
DbgControllerType
func ParseDbgControllerType ¶ added in v2.1.0
func ParseDbgControllerType(typeStr string) (DbgControllerType, error)
func (DbgControllerType) String ¶ added in v2.1.0
func (t DbgControllerType) String() string
type DesktopWindow ¶
DesktopWindow represents a single desktop window with various properties about its information.
type InterenceDevice ¶
type InterenceDevice = maa.MaaInferenceDevice
type LoggingLevel ¶
type LoggingLevel int32
const ( LoggingLevelOff LoggingLevel = iota LoggingLevelFatal LoggingLevelError LoggingLevelWarn LoggingLevelInfo LoggingLevelDebug LoggingLevelTrace LoggingLevelAll )
LoggingLevel
type NodeActionDetail ¶
type NodeDetail ¶
type NodeDetail struct { ID int64 Name string Recognition *RecognitionDetail RunCompleted bool }
type NodeNextListDetail ¶
type NodeRecognitionDetail ¶
type Notification ¶
type Notification interface { OnResourceLoading(notifyType NotificationType, detail ResourceLoadingDetail) OnControllerAction(notifyType NotificationType, detail ControllerActionDetail) OnTaskerTask(notifyType NotificationType, detail TaskerTaskDetail) OnTaskNextList(notifyType NotificationType, detail NodeNextListDetail) OnTaskRecognition(notifyType NotificationType, detail NodeRecognitionDetail) OnTaskAction(notifyType NotificationType, detail NodeActionDetail) OnUnknownNotification(msg, detailsJSON string) }
type NotificationType ¶
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 ¶
ClearCustomAction clears all custom actions registered from the resource.
func (*Resource) ClearCustomRecognition ¶
ClearCustomRecognition clears all custom recognitions registered from the resource.
func (*Resource) GetNodeJSON ¶ added in v2.3.0
GetNodeJSON gets the node JSON by name.
func (*Resource) GetNodeList ¶
GetNodeList returns the node list of the resource.
func (*Resource) OverrideNext ¶ added in v2.3.0
OverrideNext overrides the next list of task by name.
func (*Resource) OverridePipeline ¶ added in v2.3.0
OverridePipeline overrides pipeline. The `override` parameter can be a JSON string or any data type that can be marshaled to JSON.
func (*Resource) PostBundle ¶
PostBundle adds a path to the resource loading paths. Return id of the resource.
func (*Resource) RegisterCustomAction ¶
func (r *Resource) RegisterCustomAction(name string, action CustomAction) bool
RegisterCustomAction registers a custom action to the resource.
func (*Resource) RegisterCustomRecognition ¶
func (r *Resource) RegisterCustomRecognition(name string, recognition CustomRecognition) bool
RegisterCustomRecognition registers a custom recognition to the resource.
func (*Resource) UnregisterCustomAction ¶
UnregisterCustomAction unregisters a custom action from the resource.
func (*Resource) UnregisterCustomRecognition ¶
UnregisterCustomRecognition unregisters a custom recognition from the resource.
func (*Resource) UseAutoExecutionProvider ¶
UseAutoExecutionProvider
func (*Resource) UseCoreml ¶
func (r *Resource) UseCoreml(coremlFlag InterenceDevice) bool
UseCoreml
func (*Resource) UseDirectml ¶
func (r *Resource) UseDirectml(deviceID InterenceDevice) bool
UseDirectml
type ResourceLoadingDetail ¶
type TaskDetail ¶
type TaskDetail struct { ID int64 Entry string NodeDetails []*NodeDetail Status Status }
type TaskJob ¶
type TaskJob struct { *Job // contains filtered or unexported fields }
func NewTaskJob ¶
func (*TaskJob) GetDetail ¶
func (j *TaskJob) GetDetail() *TaskDetail
type Tasker ¶
type Tasker struct {
// contains filtered or unexported fields
}
func (*Tasker) BindController ¶
func (t *Tasker) BindController(ctrl Controller) bool
BindController binds the tasker to an initialized controller.
func (*Tasker) BindResource ¶
BindResource binds the tasker to an initialized resource.
func (*Tasker) GetController ¶
func (t *Tasker) GetController() Controller
GetController returns the controller handle of the tasker.
func (*Tasker) GetLatestNode ¶
func (t *Tasker) GetLatestNode(taskName string) *NodeDetail
GetLatestNode returns latest node id.
func (*Tasker) GetResource ¶
GetResource returns the resource handle of the tasker.
func (*Tasker) Initialized ¶
Initialized checks if the tasker is initialized.
type TaskerTaskDetail ¶
type Toolkit ¶
type Toolkit struct{}
func (*Toolkit) ClearPICustom ¶
ClearPICustom unregisters all custom recognitions and actions for a given instance.
func (*Toolkit) ConfigInitOption ¶
ConfigInitOption inits the toolkit config option.
func (*Toolkit) FindAdbDevices ¶
FindAdbDevices finds adb devices.
func (*Toolkit) FindDesktopWindows ¶
func (t *Toolkit) FindDesktopWindows() []*DesktopWindow
FindDesktopWindows finds desktop windows.
func (*Toolkit) RegisterPICustomAction ¶
func (t *Toolkit) RegisterPICustomAction(instId uint64, name string, action CustomAction)
RegisterPICustomAction registers a custom action.
func (*Toolkit) RegisterPICustomRecognition ¶
func (t *Toolkit) RegisterPICustomRecognition(instId uint64, name string, recognition CustomRecognition)
RegisterPICustomRecognition registers a custom recognizer.
type Win32InputMethod ¶
type Win32InputMethod uint64
Win32InputMethod
No bitwise OR, just set it.
const ( Win32InputMethodNone Win32InputMethod = 0 Win32InputMethodSeize Win32InputMethod = 1 Win32InputMethodSendMessage Win32InputMethod = 1 << 1 )
Win32InputMethod
func ParseWin32InputMethod ¶ added in v2.1.0
func ParseWin32InputMethod(methodStr string) (Win32InputMethod, error)
func (Win32InputMethod) String ¶ added in v2.1.0
func (m Win32InputMethod) String() string
type Win32ScreencapMethod ¶
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
func ParseWin32ScreencapMethod ¶ added in v2.1.0
func ParseWin32ScreencapMethod(methodStr string) (Win32ScreencapMethod, error)
func (Win32ScreencapMethod) String ¶ added in v2.1.0
func (m Win32ScreencapMethod) String() string