Documentation ¶
Index ¶
- func RegisterCustomAction(name string, action CustomAction) uint64
- func RegisterCustomRecognizer(name string, recognizer CustomRecognizer) uint64
- func SetDebugMessage(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 UnregisterCustomAction(name string) bool
- func UnregisterCustomRecognizer(name string) bool
- func Version() string
- 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, callback func(msg, detailsJson string)) Controller
- func NewDbgController(readPath, writePath string, dbgCtrlType DbgControllerType, config string, ...) Controller
- func NewWin32Controller(hWnd unsafe.Pointer, screencapMethod Win32ScreencapMethod, ...) Controller
- type CtrlOption
- type CustomAction
- type CustomController
- type CustomControllerHandler
- type CustomRecognizer
- type CustomRecognizerResult
- type DbgControllerType
- type GlobalOption
- type J
- type Job
- type LoggingLevel
- type NodeDetail
- type RecognitionDetail
- type Rect
- type Resource
- func (r *Resource) Clear() bool
- func (r *Resource) ClearCustomAction() bool
- func (r *Resource) ClearCustomRecognizer() bool
- func (r *Resource) Destroy()
- func (r *Resource) GetHash() (string, bool)
- func (r *Resource) GetTaskList() ([]string, bool)
- func (r *Resource) Handle() unsafe.Pointer
- func (r *Resource) Loaded() bool
- func (r *Resource) PostPath(path string) Job
- func (r *Resource) RegisterCustomAction(name string, action CustomAction) bool
- func (r *Resource) RegisterCustomRecognizer(name string, recognizer CustomRecognizer) bool
- func (r *Resource) UnregisterCustomAction(name string) bool
- func (r *Resource) UnregisterCustomRecognizer(name string) bool
- 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) Handle() unsafe.Pointer
- func (t *Tasker) Inited() bool
- func (t *Tasker) PostAction(entry string, override ...any) TaskJob
- func (t *Tasker) PostPipeline(entry string, override ...any) TaskJob
- func (t *Tasker) PostRecognition(entry string, override ...any) TaskJob
- func (t *Tasker) PostStop() bool
- func (t *Tasker) Running() bool
- func (t *Tasker) WaitAll()
- type Win32InputMethod
- type Win32ScreencapMethod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCustomAction ¶ added in v1.0.0
func RegisterCustomAction(name string, action CustomAction) uint64
RegisterCustomAction is a temporary function that exposes the internal registerCustomAction functionality. This function is intended for internal use within the library and should not be used by external users. This function may be removed or changed in future versions without notice.
DO NOT USE THIS FUNCTION IN YOUR CODE.
This function is expected to be moved to an internal package in the next version of the library.
func RegisterCustomRecognizer ¶ added in v1.0.0
func RegisterCustomRecognizer(name string, recognizer CustomRecognizer) uint64
RegisterCustomRecognizer is a temporary function that exposes the internal registerCustomAction functionality. This function is intended for internal use within the library and should not be used by external users. This function may be removed or changed in future versions without notice.
DO NOT USE THIS FUNCTION IN YOUR CODE.
This function is expected to be moved to an internal package in the next version of the library.
func SetDebugMessage ¶
SetDebugMessage sets whether to callback debug message.
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.
func UnregisterCustomAction ¶ added in v1.0.0
UnregisterCustomAction is a temporary function that exposes the internal registerCustomAction functionality. This function is intended for internal use within the library and should not be used by external users. This function may be removed or changed in future versions without notice.
DO NOT USE THIS FUNCTION IN YOUR CODE.
This function is expected to be moved to an internal package in the next version of the library.
func UnregisterCustomRecognizer ¶ added in v1.0.0
UnregisterCustomRecognizer is a temporary function that exposes the internal registerCustomAction functionality. This function is intended for internal use within the library and should not be used by external users. This function may be removed or changed in future versions without notice.
DO NOT USE THIS FUNCTION IN YOUR CODE.
This function is expected to be moved to an internal package in the next version of the library.
Types ¶
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 & (^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 it detail. `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.
func (*Context) RunPipeline ¶ added in v1.0.0
func (ctx *Context) RunPipeline(entry string, override ...any) *TaskDetail
RunPipeline runs a pipeline and return it detail. `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.
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 it detail. `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 Controller ¶
type Controller interface { Destroy() Handle() unsafe.Pointer SetScreenshotTargetLongSide(targetLongSide int) bool SetScreenshotTargetShortSide(targetShortSide int) bool SetRecording(recording bool) bool PostConnect() Job PostClick(x, y int32) Job PostSwipe(x1, y1, x2, y2, duration int32) 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, error) 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, callback func(msg, detailsJson string), ) Controller
NewAdbController creates an ADB controller instance.
func NewCustomController ¶
func NewCustomController( ctrl CustomController, callback func(msg, detailsJson string), ) Controller
NewCustomController creates a custom controller instance.
func NewDbgController ¶
func NewDbgController( readPath, writePath string, dbgCtrlType DbgControllerType, config string, callback func(msg, detailsJson string), ) Controller
NewDbgController creates a DBG controller instance.
func NewWin32Controller ¶
func NewWin32Controller( hWnd unsafe.Pointer, screencapMethod Win32ScreencapMethod, inputMethod Win32InputMethod, callback func(msg, detailsJson string), ) Controller
NewWin32Controller creates a win32 controller instance.
type CtrlOption ¶
type CtrlOption int32
const ( CtrlOptionInvalid CtrlOption = 0 // CtrlOptionScreenshotTargetLongSide Only one of long and short side can be set, and the other is automatically scaled according // to the aspect ratio. CtrlOptionScreenshotTargetLongSide CtrlOption = 1 // CtrlOptionScreenshotTargetShortSide Only one of long and short side can be set, and the other is automatically scaled according // to the aspect ratio. CtrlOptionScreenshotTargetShortSide CtrlOption = 2 // CtrlOptionRecording Dump all screenshots and actions // // Recording will evaluate to true if any of this or // MaaGlobalOptionEnum::MaaGlobalOption_Recording is true. CtrlOptionRecording CtrlOption = 5 )
CtrlOption
type CustomAction ¶
type CustomAction interface {
Run(ctx *Context, taskDetail *TaskDetail, currentTaskName, customActionName, customActionParam string, recognitionDetail *RecognitionDetail, box Rect) bool
}
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() unsafe.Pointer Destroy() }
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) Destroy ¶ added in v0.2.0
func (c CustomControllerHandler) Destroy()
func (CustomControllerHandler) Handle ¶ added in v0.2.0
func (c CustomControllerHandler) Handle() unsafe.Pointer
type CustomRecognizer ¶
type CustomRecognizer interface {
Run(ctx *Context, taskDetail *TaskDetail, currentTaskName, customRecognizerName, customRecognitionParam string, img image.Image, roi Rect) (CustomRecognizerResult, bool)
}
type CustomRecognizerResult ¶ added in v1.0.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 GlobalOption ¶
type GlobalOption int32
const ( GlobalOptionInvalid GlobalOption = iota // GlobalOptionLogDir Log dir // // value: string, eg: "C:\\Users\\Administrator\\Desktop\\log"; val_size: string length GlobalOptionLogDir // GlobalOptionSaveDraw Whether to save draw // // value: bool, eg: true; val_size: sizeof(bool) GlobalOptionSaveDraw // GlobalOptionRecording Dump all screenshots and actions // // Recording will evaluate to true if any of this or MaaCtrlOptionEnum::MaaCtrlOption_Recording // is true. value: bool, eg: true; val_size: sizeof(bool) GlobalOptionRecording // GlobalOptionStdoutLevel The level of log output to stdout // // value: MaaLoggingLevel, val_size: sizeof(MaaLoggingLevel) // default value is MaaLoggingLevel_Error GlobalOptionStdoutLevel // GlobalOptionShowHitDraw Whether to show hit draw // // value: bool, eg: true; val_size: sizeof(bool) GlobalOptionShowHitDraw // GlobalOptionDebugMessage Whether to callback debug message // // value: bool, eg: true; val_size: sizeof(bool) GlobalOptionDebugMessage )
GlobalOption
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 Times uint64 RunCompleted bool }
type RecognitionDetail ¶
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
func NewResource ¶
NewResource creates a new resource.
func (*Resource) ClearCustomAction ¶ added in v1.0.0
ClearCustomAction clears all custom actions registered from the resource.
func (*Resource) ClearCustomRecognizer ¶ added in v1.0.0
ClearCustomRecognizer clears all custom recognizers 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) RegisterCustomRecognizer ¶ added in v1.0.0
func (r *Resource) RegisterCustomRecognizer(name string, recognizer CustomRecognizer) bool
RegisterCustomRecognizer registers a custom recognizer to the resource.
func (*Resource) UnregisterCustomAction ¶ added in v1.0.0
UnregisterCustomAction unregisters a custom action from the resource.
func (*Resource) UnregisterCustomRecognizer ¶ added in v1.0.0
UnregisterCustomRecognizer unregisters a custom recognizer from the resource.
type TaskDetail ¶
type TaskDetail struct { ID int64 Entry string NodeDetails []*NodeDetail }
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 (job TaskJob) GetDetail() *TaskDetail
type Tasker ¶ added in v1.0.0
type Tasker struct {
// contains filtered or unexported fields
}
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) PostAction ¶ added in v1.0.0
PostAction posts an action 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.
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.
func (*Tasker) PostRecognition ¶ added in v1.0.0
PostRecognition posts a recognition 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 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