maa

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: LGPL-3.0 Imports: 10 Imported by: 1

README

LOGO

MaaFramework Golang Binding

This is the Go binding for MaaFramework, providing Go developers with a simple and effective way to use MaaFramework's features within their Go applications. Currently, the Go binding is quite rudimentary and closely mirrors the C interface. Future updates will include significant revisions to improve usability and functionality.

Installation

To install the MaaFramework Go binding, run the following command in your terminal:

go get github.com/MaaXYZ/maa-framework-go

Platform-Specific Notes

Windows

On Windows, the default location for MaaFramework is C:\maa. Ensure that MaaFramework is installed in this directory for the binding to work out of the box.

Linux and macOS

On Linux and macOS, you will need to create a pkg-config file named maa.pc. This file should correctly point to the locations of the MaaFramework headers and libraries. Place this file in a directory where pkg-config can find it (e.g., /usr/lib/pkgconfig).

A sample maa.pc file might look like this:

prefix=/path/to/maafw
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: MaaFramework
Description: MaaFramework library
Version: 1.0
Libs: -L${libdir} -lMaaFramework -lMaaToolkit
Cflags: -I${includedir}

Custom Installation Path

If you need to specify a custom installation path for MaaFramework, you can disable the default location using the -tags customenv build tag. Then, set the necessary environment variables CGO_CFLAGS and CGO_LDFLAGS.

go build -tags customenv

Set the environment variables as follows:

export CGO_CFLAGS="-I[path to maafw include directory]"
export CGO_LDFLAGS="-L[path to maafw lib directory] -lMaaFramework -lMaaToolkit"

Replace [path to maafw include directory] with the actual path to the MaaFramework include directory and [path to maafw lib directory] with the actual path to the MaaFramework library directory.

Usage

To use MaaFramework in your Go project, import the package as you would with any other Go package:

import "github.com/MaaXYZ/maa-framework-go"

Then, you can use the functionalities provided by MaaFramework. For detailed usage, refer to the examples and documentation provided in the repository.

Examples

Here is a basic example to get you started:

package main

import (
	"fmt"
	"github.com/MaaXYZ/maa-framework-go"
	"github.com/MaaXYZ/maa-framework-go/toolkit"
)

func main() {
	toolkit.InitOption("./", "{}")

	res := maa.NewResource(nil)
	defer res.Destroy()
	resJob := res.PostPath("sample/resource")
	resJob.Wait()

	devices := toolkit.AdbDevices()
	if len(devices) == 0 {
		fmt.Println("No Adb device found.")
		return
	}

	device := devices[0]
	ctrl := maa.NewAdbController(
		device.AdbPath,
		device.Address,
		device.ControllerType,
		device.Config,
		"sample/MaaAgentBinary",
		nil,
	)
	defer ctrl.Destroy()
	ctrlJob := ctrl.PostConnect()
	ctrlJob.Wait()

	inst := maa.New(nil)
	defer inst.Destroy()

	inst.BindResource(res)
	inst.BindController(ctrl)
    
	myRec := NewMyRec()
	myAct := NewMyAct()
	defer func() {
		myRec.Destroy()
		myAct.Destroy()
	}()
	inst.RegisterCustomRecognizer("MyRec", myRec)
	inst.RegisterCustomAction("MyAct", myAct)

	if !inst.Inited() {
		panic("Failed to init Maa Instance.")
	}

	taskJob := inst.PostTask("TaskA", "{}")
	taskJob.Wait()
}

type MyRec struct {
	maa.CustomRecognizerHandler
}

func NewMyRec() MyRec {
	return MyRec{
		CustomRecognizerHandler: maa.NewCustomRecognizerHandler(),
	}
}

func (MyRec) Analyze(
	ctx maa.SyncContext,
	image maa.ImageBuffer,
	taskName string,
	customRecognitionParam string,
) (maa.AnalyzeResult, bool) {
	outBox := maa.Rect{0, 0, 100, 100}
	return maa.AnalyzeResult{
		Box:    outBox,
		Detail: "Hello world.",
	}, true
}

type MyAct struct {
	maa.CustomActionHandler
}

func NewMyAct() MyAct {
	return MyAct{
		CustomActionHandler: maa.NewCustomActionHandler(),
	}
}

func (MyAct) Run(
	ctx maa.SyncContext,
	taskName string,
	customActionParam string,
	curBox maa.Rect,
	curRecDetail string,
) bool {
	return true
}

func (MyAct) Stop() {
}

Documentation

Currently, there is no detailed documentation available. Please refer to the source code and compare it with the interfaces in the original MaaFramework project to understand how to use the bindings. We are actively working on adding more comments and documentation to the source code.

Contributing

We welcome contributions to the MaaFramework Go binding. If you find a bug or have a feature request, please open an issue on the GitHub repository. If you want to contribute code, feel free to fork the repository and submit a pull request.

License

This project is licensed under the LGPL-3.0 License. See the LICENSE file for details.

Discussion

QQ Group: 595990173

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FrameworkVersion

func FrameworkVersion() string

FrameworkVersion returns the version of the framework.

func SetDebugMessage

func SetDebugMessage(enabled bool) bool

SetDebugMessage sets whether to callback debug message.

func SetLogDir

func SetLogDir(path string) bool

SetLogDir sets the log directory.

func SetRecording

func SetRecording(enabled bool) bool

SetRecording sets whether to dump all screenshots and actions.

func SetSaveDraw

func SetSaveDraw(enabled bool) bool

SetSaveDraw sets whether to save draw.

func SetShowHitDraw

func SetShowHitDraw(enabled bool) bool

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 AdbControllerType

type AdbControllerType int32
const (
	AdbControllerTypeInvalid AdbControllerType = iota

	AdbControllerTypeTouchAdb
	AdbControllerTypeTouchMiniTouch
	AdbControllerTypeTouchMaaTouch
	AdbControllerTypeTouchEmulatorExtras
	AdbControllerTypeTouchAutoDetect AdbControllerType = 0xFF - 1

	AdbControllerTypeKeyAdb            AdbControllerType = 1 << 8
	AdbControllerTypeKeyMaaTouch       AdbControllerType = 2 << 8
	AdbControllerTypeKeyEmulatorExtras AdbControllerType = 3 << 8
	AdbControllerTypeKeyAutoDetect     AdbControllerType = 0xFF00 - (1 << 8)

	AdbControllerTypeInputPresetAdb            = AdbControllerTypeTouchAdb | AdbControllerTypeKeyAdb
	AdbControllerTypeInputPresetMiniTouch      = AdbControllerTypeTouchMiniTouch | AdbControllerTypeKeyAdb
	AdbControllerTypeInputPresetMaaTouch       = AdbControllerTypeTouchMaaTouch | AdbControllerTypeKeyMaaTouch
	AdbControllerTypeInputPresetEmulatorExtras = AdbControllerTypeTouchEmulatorExtras | AdbControllerTypeKeyEmulatorExtras
	AdbControllerTypeInputPresetAutoDetect     = AdbControllerTypeTouchAutoDetect | AdbControllerTypeKeyAutoDetect

	AdbControllerTypeScreencapFastestWayCompatible AdbControllerType = 1 << 16
	AdbControllerTypeScreencapRawByNetcat          AdbControllerType = 2 << 16
	AdbControllerTypeScreencapRawWithGzip          AdbControllerType = 3 << 16
	AdbControllerTypeScreencapEncode               AdbControllerType = 4 << 16
	AdbControllerTypeScreencapEncodeToFile         AdbControllerType = 5 << 16
	AdbControllerTypeScreencapMinicapDirect        AdbControllerType = 6 << 16
	AdbControllerTypeScreencapMinicapStream        AdbControllerType = 7 << 16
	AdbControllerTypeScreencapEmulatorExtras       AdbControllerType = 8 << 16
	AdbControllerTypeScreencapFastestLosslessWay   AdbControllerType = 0xFF0000 - (2 << 16)
	AdbControllerTypeScreencapFastestWay           AdbControllerType = 0xFF0000 - (1 << 16)
)

AdbControllerType

type AnalyzeResult

type AnalyzeResult struct {
	Box    Rect
	Detail string
}

type Controller

type Controller interface {
	Destroy()
	Handle() unsafe.Pointer

	SetScreenshotTargetLongSide(targetLongSide int) bool
	SetScreenshotTargetShortSide(targetShortSide int) bool
	SetDefaultAppPackageEntry(appPackage string) bool
	SetDefaultAppPackage(appPackage string) 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
	GetImage() (image.Image, bool)
	GetUUID() (string, bool)
}

Controller is an interface that defines various methods for MAA controller.

func NewAdbController

func NewAdbController(
	adbPath, address string,
	adbCtrlType AdbControllerType,
	config, agentPath string,
	callback func(msg, detailsJson string),
) Controller

NewAdbController creates an ADB controller instance.

func NewCustomController

func NewCustomController(
	customCtrl CustomControllerImpl,
	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 NewThriftController

func NewThriftController(
	thriftCtrlType ThriftControllerType,
	host string,
	port int32,
	config string,
	callback func(msg, detailsJson string),
) Controller

NewThriftController creates a thrift controller instance.

func NewWin32Controller

func NewWin32Controller(
	hWnd unsafe.Pointer,
	win32CtrlType Win32ControllerType,
	callback func(msg, detailsJson string),
) Controller

NewWin32Controller creates a win32 controller instance.

type CtrlOption

type CtrlOption int32
const (
	CtrlOptionInvalid CtrlOption = iota

	// CtrlOptionScreenshotTargetLongSide Only one of long and short side can be set, and the other is automatically scaled according
	// to the aspect ratio.
	CtrlOptionScreenshotTargetLongSide

	// CtrlOptionScreenshotTargetShortSide Only one of long and short side can be set, and the other is automatically scaled according
	// to the aspect ratio.
	CtrlOptionScreenshotTargetShortSide

	// CtrlOptionDefaultAppPackageEntry For StartApp
	CtrlOptionDefaultAppPackageEntry

	// CtrlOptionDefaultAppPackage For StopApp
	CtrlOptionDefaultAppPackage

	// CtrlOptionRecording Dump all screenshots and actions
	//
	// Recording will evaluate to true if any of this or
	// MaaGlobalOptionEnum::MaaGlobalOption_Recording is true.
	CtrlOptionRecording
)

CtrlOption

type CustomActionHandler added in v0.2.0

type CustomActionHandler struct {
	// contains filtered or unexported fields
}

func NewCustomActionHandler added in v0.2.0

func NewCustomActionHandler() CustomActionHandler

func (CustomActionHandler) Destroy added in v0.2.0

func (a CustomActionHandler) Destroy()

func (CustomActionHandler) Handle added in v0.2.0

func (a CustomActionHandler) Handle() unsafe.Pointer

type CustomActionImpl added in v0.2.0

type CustomActionImpl interface {
	Run(ctx SyncContext, taskName, ActionParam string, curBox Rect, curRecDetail string) bool
	Stop()

	Handle() unsafe.Pointer
	Destroy()
}

CustomActionImpl defines an interface for custom action. Implementers of this interface must embed an CustomActionHandler struct and provide implementations for the Run and Stop methods.

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

type CustomControllerImpl added in v0.2.0

type CustomControllerImpl 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()
}

CustomControllerImpl 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 CustomRecognizerHandler added in v0.2.0

type CustomRecognizerHandler struct {
	// contains filtered or unexported fields
}

func NewCustomRecognizerHandler added in v0.2.0

func NewCustomRecognizerHandler() CustomRecognizerHandler

func (CustomRecognizerHandler) Destroy added in v0.2.0

func (r CustomRecognizerHandler) Destroy()

func (CustomRecognizerHandler) Handle added in v0.2.0

type CustomRecognizerImpl added in v0.2.0

type CustomRecognizerImpl interface {
	Analyze(syncCtx SyncContext, image ImageBuffer, taskName, RecognitionParam string) (AnalyzeResult, bool)

	Handle() unsafe.Pointer
	Destroy()
}

CustomRecognizerImpl defines an interface for custom recognizer. Implementers of this interface must embed a CustomRecognizerHandler struct and provide an implementation for the Analyze method.

type DbgControllerType

type DbgControllerType int32
const (
	DbgControllerTypeInvalid DbgControllerType = iota
	DbgControllerTypeCarouselImage
	DbgControllerTypeReplayRecording
)

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 ImageBuffer

type ImageBuffer interface {
	Destroy()
	Handle() unsafe.Pointer
	IsEmpty() bool
	Clear() bool

	GetByRawData() (image.Image, error)
	SetRawData(img image.Image) error

	GetByEncoded() (image.Image, error)
	SetEncoded(img image.Image) error
}

func NewImageBuffer added in v0.3.0

func NewImageBuffer() ImageBuffer

type ImageListBuffer

type ImageListBuffer interface {
	Destroy()
	Handle() unsafe.Pointer
	IsEmpty() bool
	Clear() bool
	Size() uint64
	Get(index uint64) ImageBuffer
	Append(value ImageBuffer) bool
	Remove(index uint64) bool
}

func NewImageListBuffer added in v0.3.0

func NewImageListBuffer() ImageListBuffer

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

func New

func New(callback func(msg, detailsJson string)) *Instance

New creates an instance.

func (*Instance) BindController

func (i *Instance) BindController(ctrl Controller) bool

BindController binds the instance to an initialized controller.

func (*Instance) BindResource

func (i *Instance) BindResource(res *Resource) bool

BindResource binds the instance to an initialized resource.

func (*Instance) ClearCustomAction

func (i *Instance) ClearCustomAction() bool

ClearCustomAction clears all custom actions registered to the instance.

func (*Instance) ClearCustomRecognizer

func (i *Instance) ClearCustomRecognizer() bool

ClearCustomRecognizer clears all custom recognizers registered to the instance.

func (*Instance) Destroy

func (i *Instance) Destroy()

Destroy free the instance.

func (*Instance) GetController

func (i *Instance) GetController() Controller

GetController returns the controller handle of the instance.

func (*Instance) GetResource

func (i *Instance) GetResource() *Resource

GetResource returns the resource handle of the instance.

func (*Instance) Handle

func (i *Instance) Handle() unsafe.Pointer

Handle returns the instance handle.

func (*Instance) Inited

func (i *Instance) Inited() bool

Inited checks if the instance is initialized.

func (*Instance) PostAction

func (i *Instance) PostAction(entry, param string) TaskJob

PostAction posts an action to the instance.

func (*Instance) PostRecognition

func (i *Instance) PostRecognition(entry, param string) TaskJob

PostRecognition posts a recognition to the instance.

func (*Instance) PostStop

func (i *Instance) PostStop() bool

PostStop posts a stop signal to the instance.

func (*Instance) PostTask

func (i *Instance) PostTask(entry, param string) TaskJob

PostTask posts a task to the instance.

func (*Instance) RegisterCustomAction

func (i *Instance) RegisterCustomAction(name string, action CustomActionImpl) bool

RegisterCustomAction registers a custom action to the instance.

func (*Instance) RegisterCustomRecognizer

func (i *Instance) RegisterCustomRecognizer(name string, recognizer CustomRecognizerImpl) bool

RegisterCustomRecognizer registers a custom recognizer to the instance.

func (*Instance) Running

func (i *Instance) Running() bool

Running checks if the instance running.

func (*Instance) UnregisterCustomAction

func (i *Instance) UnregisterCustomAction(name string) bool

UnregisterCustomAction unregisters a custom action from the instance.

func (*Instance) UnregisterCustomRecognizer

func (i *Instance) UnregisterCustomRecognizer(name string) bool

UnregisterCustomRecognizer unregisters a custom recognizer from the instance.

func (*Instance) WaitAll added in v0.4.0

func (i *Instance) WaitAll()

WaitAll waits for all tasks to complete.

type Job added in v0.4.0

type Job struct {
	// contains filtered or unexported fields
}

func NewJob added in v0.4.0

func NewJob(id int64, statusFunc func(id int64) Status) Job

func (Job) Done added in v0.4.0

func (job Job) Done() bool

func (Job) Failure added in v0.4.0

func (job Job) Failure() bool

func (Job) Invalid added in v0.4.0

func (job Job) Invalid() bool

func (Job) Pending added in v0.4.0

func (job Job) Pending() bool

func (Job) Running added in v0.4.0

func (job Job) Running() bool

func (Job) Status added in v0.4.0

func (job Job) Status() Status

func (Job) Success added in v0.4.0

func (job Job) Success() bool

func (Job) Wait added in v0.4.0

func (job Job) Wait() bool

type LoggingLevel

type LoggingLevel int32
const (
	LoggingLevelOff LoggingLevel = iota
	LoggingLevelFatal
	LoggingLevelError
	LoggingLevelWarn
	LoggingLevelInfo
	LoggingLevelDebug
	LoggingLevelTrace
	LoggingLevelAll
)

LoggingLevel

type NodeDetail

type NodeDetail struct {
	Name         string
	RecId        int64
	RunCompleted bool
}

func QueryNodeDetail

func QueryNodeDetail(nodeId int64) (*NodeDetail, bool)

QueryNodeDetail queries running detail.

type RecognitionDetail

type RecognitionDetail struct {
	Name       string
	Hit        bool
	DetailJson string
	Raw        ImageBuffer
	Draws      ImageListBuffer
}

func QueryRecognitionDetail

func QueryRecognitionDetail(recId int64) (RecognitionDetail, bool)

QueryRecognitionDetail queries recognition detail.

type RecognitionResult added in v0.3.0

type RecognitionResult struct {
	Box    Rect
	Detail string
}

type Rect added in v0.3.0

type Rect [4]int32

func (*Rect) GetH added in v0.3.0

func (r *Rect) GetH() int32

func (*Rect) GetW added in v0.3.0

func (r *Rect) GetW() int32

func (*Rect) GetX added in v0.3.0

func (r *Rect) GetX() int32

func (*Rect) GetY added in v0.3.0

func (r *Rect) GetY() int32

func (*Rect) SetH added in v0.3.0

func (r *Rect) SetH(value int32)

func (*Rect) SetW added in v0.3.0

func (r *Rect) SetW(value int32)

func (*Rect) SetX added in v0.3.0

func (r *Rect) SetX(value int32)

func (*Rect) SetY added in v0.3.0

func (r *Rect) SetY(value int32)

type RectBuffer

type RectBuffer interface {
	Destroy()
	Handle() unsafe.Pointer
	Get() Rect
	GetX() int32
	GetY() int32
	GetW() int32
	GetH() int32
	Set(rect Rect) bool

	SetY(value int32) bool
	SetW(value int32) bool
	SetH(value int32) bool
	// contains filtered or unexported methods
}

func NewRectBuffer added in v0.3.0

func NewRectBuffer() RectBuffer

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

func NewResource

func NewResource(callback func(msg, detailsJson string)) *Resource

NewResource creates a new resource.

func (*Resource) Clear

func (r *Resource) Clear() bool

Clear clears the resource loading paths.

func (*Resource) Destroy

func (r *Resource) Destroy()

Destroy frees the resource.

func (*Resource) GetHash

func (r *Resource) GetHash() (string, bool)

GetHash returns the hash of the resource.

func (*Resource) GetTaskList

func (r *Resource) GetTaskList() ([]string, bool)

GetTaskList returns the task list of the resource.

func (*Resource) Loaded

func (r *Resource) Loaded() bool

Loaded checks if resources are loaded.

func (*Resource) PostPath

func (r *Resource) PostPath(path string) Job

PostPath adds a path to the resource loading paths. Return id of the resource.

type Status

type Status int32
const (
	StatusInvalid Status = 0
	StatusPending Status = 1000
	StatusRunning Status = 2000
	StatusSuccess Status = 3000
	StatusFailure Status = 4000
)

func (Status) Done added in v0.4.0

func (status Status) Done() bool

func (Status) Failure added in v0.4.0

func (status Status) Failure() bool

func (Status) Invalid added in v0.4.0

func (status Status) Invalid() bool

func (Status) Pending added in v0.4.0

func (status Status) Pending() bool

func (Status) Running added in v0.4.0

func (status Status) Running() bool

func (Status) Success added in v0.4.0

func (status Status) Success() bool

type StringBuffer

type StringBuffer interface {
	Destroy()
	Handle() unsafe.Pointer
	IsEmpty() bool
	Clear() bool
	Get() string
	Size() uint64
	Set(str string) bool
	SetWithSize(str string, size uint64) bool
}

func NewStringBuffer added in v0.3.0

func NewStringBuffer() StringBuffer

type StringListBuffer

type StringListBuffer interface {
	Destroy()
	IsEmpty() bool
	Clear() bool
	Size() uint64
	Get(index uint64) string
	Append(value StringBuffer) bool
	Remove(index uint64) bool
}

func NewStringListBuffer added in v0.3.0

func NewStringListBuffer() StringListBuffer

type SyncContext

type SyncContext struct {
	// contains filtered or unexported fields
}

func (SyncContext) CacheImage added in v0.3.0

func (ctx SyncContext) CacheImage() (ImageBuffer, bool)

func (SyncContext) Click added in v0.3.0

func (ctx SyncContext) Click(x, y int32) bool

func (SyncContext) InputText added in v0.3.0

func (ctx SyncContext) InputText(text string) bool

func (SyncContext) PressKey added in v0.3.0

func (ctx SyncContext) PressKey(keycode int32) bool

func (SyncContext) RunAction added in v0.3.0

func (ctx SyncContext) RunAction(taskName, taskParam string, curBox Rect, curRecDetail string) bool

func (SyncContext) RunRecognition added in v0.3.0

func (ctx SyncContext) RunRecognition(image ImageBuffer, taskName, taskParam string) (RecognitionResult, bool)

func (SyncContext) RunTask added in v0.3.0

func (ctx SyncContext) RunTask(taskName, param string) bool

func (SyncContext) Screencap added in v0.3.0

func (ctx SyncContext) Screencap() (ImageBuffer, bool)

func (SyncContext) Swipe added in v0.3.0

func (ctx SyncContext) Swipe(x1, y1, x2, y2, duration int32) bool

func (SyncContext) TouchDown added in v0.3.0

func (ctx SyncContext) TouchDown(contact, x, y, pressure int32) bool

func (SyncContext) TouchMove added in v0.3.0

func (ctx SyncContext) TouchMove(contact, x, y, pressure int32) bool

func (SyncContext) TouchUp added in v0.3.0

func (ctx SyncContext) TouchUp(contact int32) bool

type TaskDetail

type TaskDetail struct {
	Entry      string
	NodeIdList []int64
}

func QueryTaskDetail

func QueryTaskDetail(taskId int64) (*TaskDetail, bool)

QueryTaskDetail queries task detail.

type TaskJob added in v0.4.0

type TaskJob struct {
	// contains filtered or unexported fields
}

func NewTaskJob added in v0.4.0

func NewTaskJob(id int64, statusFunc func(id int64) Status, setParamFunc func(id int64, param string) bool) TaskJob

func (TaskJob) Done added in v0.4.0

func (job TaskJob) Done() bool

func (TaskJob) Failure added in v0.4.0

func (job TaskJob) Failure() bool

func (TaskJob) GetDetail added in v0.4.0

func (job TaskJob) GetDetail() (*TaskDetail, bool)

func (TaskJob) Invalid added in v0.4.0

func (job TaskJob) Invalid() bool

func (TaskJob) Pending added in v0.4.0

func (job TaskJob) Pending() bool

func (TaskJob) Running added in v0.4.0

func (job TaskJob) Running() bool

func (TaskJob) SetParam added in v0.4.0

func (job TaskJob) SetParam(param string) bool

func (TaskJob) Status added in v0.4.0

func (job TaskJob) Status() Status

func (TaskJob) Success added in v0.4.0

func (job TaskJob) Success() bool

func (TaskJob) Wait added in v0.4.0

func (job TaskJob) Wait() bool

type ThriftControllerType

type ThriftControllerType int32
const (
	ThriftControllerInvalid ThriftControllerType = iota
	ThriftControllerTypeSocket
	ThriftControllerTypeUnixDomainSocket
)

type Win32ControllerType

type Win32ControllerType int32
const (
	Win32ControllerTypeInvalid Win32ControllerType = iota

	Win32ControllerTypeTouchSendMessage
	Win32ControllerTypeTouchSeize

	Win32ControllerTypeKeySendMessage Win32ControllerType = 1 << 8
	Win32ControllerTypeKeySeize       Win32ControllerType = 2 << 8

	Win32ControllerTypeScreencapGDI            Win32ControllerType = 1 << 16
	Win32ControllerTypeScreencapDXGIDesktopDup Win32ControllerType = 2 << 16
	Win32ControllerTypeScreencapDXGIFramePool  Win32ControllerType = 4 << 16
)

Win32ControllerType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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