maa

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// I don't recommend setting up MaaResOption_InferenceDevice in this case,
	// because you don't know which EP will be used on different user devices.
	MaaInferenceExecutionProvider_Auto = 0

	// MaaResOption_InferenceDevice will not work.
	MaaInferenceExecutionProvider_CPU = 1

	// MaaResOption_InferenceDevice will be used to set adapter id,
	// It's from Win32 API `EnumAdapters1`.
	MaaInferenceExecutionProvider_DirectML = 2

	// MaaResOption_InferenceDevice will be used to set coreml_flag,
	// Reference to
	// https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/providers/coreml/coreml_provider_factory.h
	// But you need to pay attention to the onnxruntime version we use, the latest flag may not be supported.
	MaaInferenceExecutionProvider_CoreML = 3

	// MaaResOption_InferenceDevice will be used to set NVIDIA GPU ID
	// TODO!
	MaaInferenceExecutionProvider_CUDA = 4
)

Variables

View Source
var (
	MaaTaskerCreate               func(notify MaaNotificationCallback, notifyTransArg uintptr) uintptr
	MaaTaskerDestroy              func(tasker uintptr)
	MaaTaskerSetOption            func(tasker uintptr, key MaaTaskerOption, value unsafe.Pointer, valSize uint64) bool
	MaaTaskerBindResource         func(tasker uintptr, res uintptr) bool
	MaaTaskerBindController       func(tasker uintptr, ctrl uintptr) bool
	MaaTaskerInited               func(tasker uintptr) bool
	MaaTaskerPostPipeline         func(tasker uintptr, entry, pipelineOverride string) int64
	MaaTaskerStatus               func(tasker uintptr, id int64) int32
	MaaTaskerWait                 func(tasker uintptr, id int64) int32
	MaaTaskerRunning              func(tasker uintptr) bool
	MaaTaskerPostStop             func(tasker uintptr) int64
	MaaTaskerGetResource          func(tasker uintptr) uintptr
	MaaTaskerGetController        func(tasker uintptr) uintptr
	MaaTaskerClearCache           func(tasker uintptr) bool
	MaaTaskerGetRecognitionDetail func(tasker uintptr, recoId int64, name uintptr, algorithm uintptr, hit *bool, box uintptr, detailJson uintptr, raw uintptr, draws uintptr) bool
	MaaTaskerGetNodeDetail        func(tasker uintptr, nodeId int64, name uintptr, recoId *int64, completed *bool) bool
	MaaTaskerGetTaskDetail        func(tasker uintptr, taskId int64, entry uintptr, nodeIdList uintptr, nodeIdListSize *uint64, status *int32) bool
	MaaTaskerGetLatestNode        func(tasker uintptr, taskName string, latestId *int64) bool
)
View Source
var (
	MaaResourceCreate                      func(notify MaaNotificationCallback, notifyTransArg uintptr) uintptr
	MaaResourceDestroy                     func(res uintptr)
	MaaResourceRegisterCustomRecognition   func(res uintptr, name string, recognition MaaCustomRecognitionCallback, transArg uintptr) bool
	MaaResourceUnregisterCustomRecognition func(res uintptr, name string) bool
	MaaResourceClearCustomRecognition      func(res uintptr) bool
	MaaResourceRegisterCustomAction        func(res uintptr, name string, action MaaCustomActionCallback, transArg uintptr) bool
	MaaResourceUnregisterCustomAction      func(res uintptr, name string) bool
	MaaResourceClearCustomAction           func(res uintptr) bool
	MaaResourcePostPath                    func(res uintptr, path string) int64
	MaaResourceClear                       func(res uintptr) bool
	MaaResourceStatus                      func(res uintptr, id int64) int32
	MaaResourceWait                        func(res uintptr, id int64) int32
	MaaResourceLoaded                      func(res uintptr) bool
	MaaResourceSetOption                   func(res uintptr, key MaaResOption, value unsafe.Pointer, valSize uint64) bool
	MaaResourceGetHash                     func(res uintptr, buffer uintptr) bool
	MaaResourceGetTaskList                 func(res uintptr, buffer uintptr) bool
)
View Source
var (
	MaaAdbControllerCreate      func(adbPath, address string, screencapMethods MaaAdbScreencapMethod, inputMethods MaaAdbInputMethod, config, agentPath string, notify MaaNotificationCallback, notifyTransArg uintptr) uintptr
	MaaWin32ControllerCreate    func(hWnd unsafe.Pointer, screencapMethods MaaWin32ScreencapMethod, inputMethods MaaWin32InputMethod, notify MaaNotificationCallback, notifyTransArg uintptr) uintptr
	MaaCustomControllerCreate   func(controller uintptr, controllerArg uintptr, notify MaaNotificationCallback, notifyTransArg uintptr) uintptr
	MaaDbgControllerCreate      func(readPath, writePath string, dbgCtrlType MaaDbgControllerType, config string, notify MaaNotificationCallback, notifyTransArg uintptr) uintptr
	MaaControllerDestroy        func(ctrl uintptr)
	MaaControllerSetOption      func(ctrl uintptr, key MaaCtrlOption, value unsafe.Pointer, valSize uint64) bool
	MaaControllerPostConnection func(ctrl uintptr) int64
	MaaControllerPostClick      func(ctrl uintptr, x, y int32) int64
	MaaControllerPostSwipe      func(ctrl uintptr, x1, y1, x2, y2, duration int32) int64
	MaaControllerPostPressKey   func(ctrl uintptr, keycode int32) int64
	MaaControllerPostInputText  func(ctrl uintptr, text string) int64
	MaaControllerPostStartApp   func(ctrl uintptr, intent string) int64
	MaaControllerPostStopApp    func(ctrl uintptr, intent string) int64
	// for adb controller, contact means finger id (0 for first finger, 1 for second finger, etc)
	// for win32 controller, contact means mouse button id (0 for left, 1 for right, 2 for middle)
	MaaControllerPostTouchDown func(ctrl uintptr, contact, x, y, pressure int32) int64
	MaaControllerPostTouchMove func(ctrl uintptr, contact, x, y, pressure int32) int64
	// for adb controller, contact means finger id (0 for first finger, 1 for second finger, etc)
	// for win32 controller, contact means mouse button id (0 for left, 1 for right, 2 for middle)
	MaaControllerPostTouchUp   func(ctrl uintptr, contact int32) int64
	MaaControllerPostScreencap func(ctrl uintptr) int64
	MaaControllerStatus        func(ctrl uintptr, id int64) int32
	MaaControllerWait          func(ctrl uintptr, id int64) int32
	MaaControllerConnected     func(ctrl uintptr) bool
	MaaControllerCachedImage   func(ctrl uintptr, buffer uintptr) bool
	MaaControllerGetUuid       func(ctrl uintptr, buffer uintptr) bool
)
View Source
var (
	MaaContextRunPipeline      func(context uintptr, entry, pipelineOverride string) int64
	MaaContextRunRecognition   func(context uintptr, entry, pipelineOverride string, image uintptr) int64
	MaaContextRunAction        func(context uintptr, entry, pipelineOverride string, box uintptr, recoDetail string) int64
	MaaContextOverridePipeline func(context uintptr, pipelineOverride string) bool
	MaaContextOverrideNext     func(context uintptr, name string, nextList uintptr) bool
	MaaContextGetTaskId        func(context uintptr) int64
	MaaContextGetTasker        func(context uintptr) uintptr
	MaaContextClone            func(context uintptr) uintptr
)
View Source
var (
	MaaStringBufferCreate  func() uintptr
	MaaStringBufferDestroy func(handle uintptr)
	MaaStringBufferIsEmpty func(handle uintptr) bool
	MaaStringBufferClear   func(handle uintptr) bool
	MaaStringBufferGet     func(handle uintptr) string
	MaaStringBufferSize    func(handle uintptr) uint64
	MaaStringBufferSet     func(handle uintptr, str string) bool
	MaaStringBufferSetEx   func(handle uintptr, str string, size uint64) bool

	MaaStringListBufferCreate  func() uintptr
	MaaStringListBufferDestroy func(handle uintptr)
	MaaStringListBufferIsEmpty func(handle uintptr) bool
	MaaStringListBufferSize    func(handle uintptr) uint64
	MaaStringListBufferAt      func(handle uintptr, index uint64) uintptr
	MaaStringListBufferAppend  func(handle uintptr, value uintptr) bool
	MaaStringListBufferRemove  func(handle uintptr, index uint64) bool
	MaaStringListBufferClear   func(handle uintptr) bool

	MaaImageBufferCreate     func() uintptr
	MaaImageBufferDestroy    func(handle uintptr)
	MaaImageBufferIsEmpty    func(handle uintptr) bool
	MaaImageBufferClear      func(handle uintptr) bool
	MaaImageBufferGetRawData func(handle uintptr) unsafe.Pointer
	MaaImageBufferWidth      func(handle uintptr) int32
	MaaImageBufferHeight     func(handle uintptr) int32
	MaaImageBufferChannels   func(handle uintptr) int32
	MaaImageBufferType       func(handle uintptr) int32
	MaaImageBufferSetRawData func(handle uintptr, data unsafe.Pointer, width, height, imageType int32) bool

	MaaImageListBufferCreate  func() uintptr
	MaaImageListBufferDestroy func(handle uintptr)
	MaaImageListBufferIsEmpty func(handle uintptr) bool
	MaaImageListBufferSize    func(handle uintptr) uint64
	MaaImageListBufferAt      func(handle uintptr, index uint64) uintptr
	MaaImageListBufferAppend  func(handle uintptr, value uintptr) bool
	MaaImageListBufferRemove  func(handle uintptr, index uint64) bool
	MaaImageListBufferClear   func(handle uintptr) bool

	MaaRectCreate  func() uintptr
	MaaRectDestroy func(handle uintptr)
	MaaRectGetX    func(handle uintptr) int32
	MaaRectGetY    func(handle uintptr) int32
	MaaRectGetW    func(handle uintptr) int32
	MaaRectGetH    func(handle uintptr) int32
	MaaRectSet     func(handle uintptr, x, y, w, h int32) bool
)
View Source
var (
	MaaToolkitProjectInterfaceRegisterCustomRecognition func(instId uint64, name string, recognition MaaCustomRecognitionCallback, transArg unsafe.Pointer)
	MaaToolkitProjectInterfaceRegisterCustomAction      func(instId uint64, name string, action MaaCustomActionCallback, transArg unsafe.Pointer)
	MaaToolkitProjectInterfaceRunCli                    func(instId uint64, resourcePath, userPath string, directly bool, notify MaaNotificationCallback, notifyTransArg unsafe.Pointer) bool
)
View Source
var (
	MaaToolkitAdbDeviceListCreate          func() uintptr
	MaaToolkitAdbDeviceListDestroy         func(handle uintptr)
	MaaToolkitAdbDeviceFind                func(buffer uintptr) bool
	MaaToolkitAdbDeviceFindSpecified       func(adbPath string, buffer uintptr) bool
	MaaToolkitAdbDeviceListSize            func(list uintptr) uint64
	MaaToolkitAdbDeviceListAt              func(list uintptr, index uint64) uintptr
	MaaToolkitAdbDeviceGetName             func(device uintptr) string
	MaaToolkitAdbDeviceGetAdbPath          func(device uintptr) string
	MaaToolkitAdbDeviceGetAddress          func(device uintptr) string
	MaaToolkitAdbDeviceGetScreencapMethods func(device uintptr) int32
	MaaToolkitAdbDeviceGetInputMethods     func(device uintptr) int32
	MaaToolkitAdbDeviceGetConfig           func(device uintptr) string
)
View Source
var (
	MaaToolkitDesktopWindowListCreate    func() uintptr
	MaaToolkitDesktopWindowListDestroy   func(handle uintptr)
	MaaToolkitDesktopWindowFindAll       func(buffer uintptr) bool
	MaaToolkitDesktopWindowListSize      func(list uintptr) uint64
	MaaToolkitDesktopWindowListAt        func(list uintptr, index uint64) uintptr
	MaaToolkitDesktopWindowGetHandle     func(window uintptr) unsafe.Pointer
	MaaToolkitDesktopWindowGetClassName  func(window uintptr) string
	MaaToolkitDesktopWindowGetWindowName func(window uintptr) string
)
View Source
var MaaSetGlobalOption func(key MaaGlobalOption, value unsafe.Pointer, valSize uint64) bool
View Source
var MaaToolkitConfigInitOption func(userPath, defaultJson string) bool
View Source
var (
	MaaVersion func() string
)

Functions

func MaaCustomControllerCallbacksCreate

func MaaCustomControllerCallbacksCreate(
	connect ConnectCallback,
	requestUUID RequestUUIDCallback,
	startApp StartAppCallback,
	stopApp StopAppCallback,
	screencap ScreencapCallback,
	click ClickCallback,
	swipe SwipeCallback,
	touchDown TouchDownCallback,
	touchMove TouchMoveCallback,
	touchUp TouchUpCallback,
	pressKey PressKeyCallback,
	inputText InputTextCallback,
) uintptr

Types

type ClickCallback

type ClickCallback func(x, y int32, transArg uintptr) bool

type ConnectCallback

type ConnectCallback func(transArg uintptr) bool

type InputTextCallback

type InputTextCallback func(text string, transArg uintptr) bool

type MaaAdbInputMethod

type MaaAdbInputMethod uint64

MaaAdbInputMethod

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 (
	MaaAdbInputMethod_None               MaaAdbInputMethod = 0
	MaaAdbInputMethod_AdbShell           MaaAdbInputMethod = 1
	MaaAdbInputMethod_MinitouchAndAdbKey MaaAdbInputMethod = 1 << 1
	MaaAdbInputMethod_Maatouch           MaaAdbInputMethod = 1 << 2
	MaaAdbInputMethod_EmulatorExtras     MaaAdbInputMethod = 1 << 3

	MaaAdbInputMethod_All     = ^MaaAdbInputMethod_None
	MaaAdbInputMethod_Default = MaaAdbInputMethod_All & (^MaaAdbInputMethod_EmulatorExtras)
)

type MaaAdbScreencapMethod

type MaaAdbScreencapMethod uint64

MaaAdbScreencapMethod

Use bitwise OR to set the method you need, MaaFramework will test their speed and use the fastest one.

const (
	MaaAdbScreencapMethod_None                MaaAdbScreencapMethod = 0
	MaaAdbScreencapMethod_EncodeToFileAndPull MaaAdbScreencapMethod = 1
	MaaAdbScreencapMethod_Encode              MaaAdbScreencapMethod = 1 << 1
	MaaAdbScreencapMethod_RawWithGzip         MaaAdbScreencapMethod = 1 << 2
	MaaAdbScreencapMethod_RawByNetcat         MaaAdbScreencapMethod = 1 << 3
	MaaAdbScreencapMethod_MinicapDirect       MaaAdbScreencapMethod = 1 << 4
	MaaAdbScreencapMethod_MinicapStream       MaaAdbScreencapMethod = 1 << 5
	MaaAdbScreencapMethod_EmulatorExtras      MaaAdbScreencapMethod = 1 << 6

	MaaAdbScreencapMethod_All     = ^MaaAdbScreencapMethod_None
	MaaAdbScreencapMethod_Default = MaaAdbScreencapMethod_All & (^MaaAdbScreencapMethod_MinicapDirect) & (^MaaAdbScreencapMethod_MinicapStream)
)

type MaaCtrlOption

type MaaCtrlOption int32
const (
	MaaCtrlOption_Invalid MaaCtrlOption = 0

	// MaaCtrlOptionScreenshotTargetLongSide specifies that only the long side can be set, and the short side
	// is automatically scaled according to the aspect ratio.
	MaaCtrlOption_ScreenshotTargetLongSide MaaCtrlOption = 1

	// MaaCtrlOptionScreenshotTargetShortSide specifies that only the short side can be set, and the long side
	// is automatically scaled according to the aspect ratio.
	MaaCtrlOption_ScreenshotTargetShortSide MaaCtrlOption = 2

	// MaaCtrlOptionScreenshotUseRawSize specifies that the screenshot uses the raw size without scaling.
	// Note that this option may cause incorrect coordinates on user devices with different resolutions if scaling is not performed.
	MaaCtrlOption_ScreenshotUseRawSize MaaCtrlOption = 3

	/// MaaCtrlOptionRecording indicates that all screenshots and actions should be dumped.
	// Recording will evaluate to true if either this or MaaGlobalOptionEnum::MaaGlobalOption_Recording is true.
	MaaCtrlOption_Recording MaaCtrlOption = 5
)

type MaaCustomActionCallback

type MaaCustomActionCallback func(context uintptr, taskId int64, currentTaskName, customActionName, customActionParam *byte, recoId int64, box uintptr, transArg uintptr) uint64

type MaaCustomControllerCallbacks

type MaaCustomControllerCallbacks struct {
	Connect     uintptr
	RequestUUID uintptr
	StartApp    uintptr
	StopApp     uintptr
	Screencap   uintptr
	Click       uintptr
	Swipe       uintptr
	TouchDown   uintptr
	TouchMove   uintptr
	TouchUp     uintptr
	PressKey    uintptr
	InputText   uintptr
}

type MaaCustomRecognitionCallback

type MaaCustomRecognitionCallback func(context uintptr, taskId int64, currentTaskName, customRecognitionName, customRecognitionParam *byte, image, roi uintptr, transArg uintptr, outBox, outDetail uintptr) uint64

type MaaDbgControllerType

type MaaDbgControllerType uint64

DbgControllerType

No bitwise OR, just set it.

const (
	MaaDbgControllerType_None            MaaDbgControllerType = 0
	MaaDbgControllerType_CarouselImage   MaaDbgControllerType = 1
	MaaDbgControllerType_ReplayRecording MaaDbgControllerType = 1 << 1
)

type MaaGlobalOption

type MaaGlobalOption int32
const (
	MaaGlobalOption_Invalid MaaGlobalOption = iota

	// MaaGlobalOption_LogDir Log dir
	//
	// value: string, eg: "C:\\Users\\Administrator\\Desktop\\log"; val_size: string length
	MaaGlobalOption_LogDir

	// MaaGlobalOption_SaveDraw Whether to save draw
	//
	// value: bool, eg: true; val_size: sizeof(bool)
	MaaGlobalOption_SaveDraw

	// MaaGlobalOption_Recording 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)
	MaaGlobalOption_Recording

	// MaaGlobalOption_StdoutLevel The level of log output to stdout
	//
	// value: MaaLoggingLevel, val_size: sizeof(MaaLoggingLevel)
	// default value is MaaLoggingLevel_Error
	MaaGlobalOption_StdoutLevel

	// MaaGlobalOption_ShowHitDraw Whether to show hit draw
	//
	// value: bool, eg: true; val_size: sizeof(bool)
	MaaGlobalOption_ShowHitDraw

	// MaaGlobalOption_DebugMode Whether to debug
	//
	// value: bool, eg: true; val_size: sizeof(bool)
	MaaGlobalOption_DebugMode
)

type MaaInferenceDevice added in v1.7.0

type MaaInferenceDevice int32
const (
	MaaInferenceDevice_CPU  MaaInferenceDevice = -2
	MaaInferenceDevice_Auto MaaInferenceDevice = -1
	MaaInferenceDevice_0    MaaInferenceDevice = 0
	MaaInferenceDevice_1    MaaInferenceDevice = 1
)

type MaaInferenceExecutionProvider added in v1.7.0

type MaaInferenceExecutionProvider int32

type MaaNotificationCallback

type MaaNotificationCallback func(message, detailsJson *byte, notifyTransArg uintptr) uintptr

type MaaResOption

type MaaResOption int32
const (
	MaaResOption_Invalid MaaResOption = 0

	/// Use the specified inference device.
	/// Please set this option before loading the model.
	///
	/// value: MaaInferenceDevice, eg: 0; val_size: sizeof(MaaInferenceDevice)
	/// default value is MaaInferenceDevice_Auto
	MaaResOption_InferenceDevice MaaResOption = 1

	/// Use the specified inference execution provider
	/// Please set this option before loading the model.
	///
	/// value: MaaInferenceExecutionProvider, eg: 0; val_size: sizeof(MaaInferenceExecutionProvider)
	/// default value is MaaInferenceExecutionProvider_Auto
	MaaResOption_InferenceExecutionProvider MaaResOption = 2
)

type MaaTaskerOption

type MaaTaskerOption int32

type MaaWin32InputMethod

type MaaWin32InputMethod uint64

MaaWin32InputMethod

No bitwise OR, just set it.

type MaaWin32ScreencapMethod

type MaaWin32ScreencapMethod uint64

MaaWin32ScreencapMethod

No bitwise OR, just set it.

const (
	MaaWin32ScreencapMethod_None           MaaWin32ScreencapMethod = 0
	MaaWin32ScreencapMethod_GDI            MaaWin32ScreencapMethod = 1
	MaaWin32ScreencapMethod_FramePool      MaaWin32ScreencapMethod = 1 << 1
	MaaWin32ScreencapMethod_DXGIDesktopDup MaaWin32ScreencapMethod = 1 << 2
)
const (
	MaaWin32InputMethod_None        MaaWin32ScreencapMethod = 0
	MaaWin32InputMethod_Seize       MaaWin32ScreencapMethod = 1
	MaaWin32InputMethod_SendMessage MaaWin32ScreencapMethod = 1 << 1
)

type PressKeyCallback

type PressKeyCallback func(keycode int32, transArg uintptr) bool

type RequestUUIDCallback

type RequestUUIDCallback func(transArg uintptr, buffer uintptr) bool

type ScreencapCallback

type ScreencapCallback func(transArg uintptr, buffer uintptr) bool

type StartAppCallback

type StartAppCallback func(intent string, transArg uintptr) bool

type StopAppCallback

type StopAppCallback func(intent string, transArg uintptr) bool

type SwipeCallback

type SwipeCallback func(x1, y1, x2, y2, duration int32, transArg uintptr) bool

type TouchDownCallback

type TouchDownCallback func(contact, x, y, pressure int32, transArg uintptr) bool

type TouchMoveCallback

type TouchMoveCallback func(contact, x, y, pressure int32, transArg uintptr) bool

type TouchUpCallback

type TouchUpCallback func(contact int32, transArg uintptr) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL