maa

package module
v1.0.0 Latest Latest
Warning

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

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

README

LOGO

MaaFramework Golang Binding

license go reference maa framework

English | 简体中文

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.

Installation

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

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

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.

Documentation

Currently, there is not much 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.

Here are some documents from the maa framework that might help you:

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.

If you need to specify a custom installation path, refer to the Custom Environment section.

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}

If you need to specify a custom environment, refer to the Custom Environment section.

Custom Environment

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.

Examples

Quirk start

See quirk-start for details.

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"
	"os"
)

func main() {
	toolkit.ConfigInitOption("./", "{}")
	tasker := maa.NewTasker(nil)
	defer tasker.Destroy()

	deviceFinder := toolkit.NewAdbDeviceFinder()
	deviceFinder.Find()
	device := deviceFinder.Find()[0]
	ctrl := maa.NewAdbController(
		device.GetAdbPath(),
		device.GetAddress(),
		device.GetScreencapMethod(),
		device.GetInputMethod(),
		device.GetConfig(),
		"path/to/MaaAgentBinary",
		nil,
	)
	defer ctrl.Destroy()
	ctrl.PostConnect().Wait()
	tasker.BindController(ctrl)

	res := maa.NewResource(nil)
	defer res.Destroy()
	res.PostPath("./resource").Wait()
	tasker.BindResource(res)
	if tasker.Inited() {
		fmt.Println("Failed to init MAA.")
		os.Exit(1)
	}

	tasker.PostPipeline("Startup")
}

Custom Recognizer

See custom-recognizer for details.

Here is a basic example to implement your custom recognizer:

package main

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

func main() {
	toolkit.ConfigInitOption("./", "{}")
	tasker := maa.NewTasker(nil)
	defer tasker.Destroy()

	deviceFinder := toolkit.NewAdbDeviceFinder()
	deviceFinder.Find()
	device := deviceFinder.Find()[0]
	ctrl := maa.NewAdbController(
		device.GetAdbPath(),
		device.GetAddress(),
		device.GetScreencapMethod(),
		device.GetInputMethod(),
		device.GetConfig(),
		"path/to/MaaAgentBinary",
		nil,
	)
	defer ctrl.Destroy()
	ctrl.PostConnect().Wait()
	tasker.BindController(ctrl)

	res := maa.NewResource(nil)
	defer res.Destroy()
	res.PostPath("./resource").Wait()
	tasker.BindResource(res)
	if tasker.Inited() {
		fmt.Println("Failed to init MAA.")
		os.Exit(1)
	}

	res.RegisterCustomRecognizer("MyRec", &MyRec{})

	tasker.PostPipeline("Startup")
}

type MyRec struct{}

func (r *MyRec) Run(_ *maa.Context, _ *maa.TaskDetail, _, _, _ string, _ image.Image, _ maa.Rect) (maa.CustomRecognizerResult, bool) {
	return maa.CustomRecognizerResult{
		Box:    maa.Rect{0, 0, 100, 100},
		Detail: "Hello World!",
	}, true
}

Custom Action

See custom-action for details.

Here is a basic example to implement your custom action:

package main

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

func main() {
	toolkit.ConfigInitOption("./", "{}")
	tasker := maa.NewTasker(nil)
	defer tasker.Destroy()

	deviceFinder := toolkit.NewAdbDeviceFinder()
	deviceFinder.Find()
	device := deviceFinder.Find()[0]
	ctrl := maa.NewAdbController(
		device.GetAdbPath(),
		device.GetAddress(),
		device.GetScreencapMethod(),
		device.GetInputMethod(),
		device.GetConfig(),
		"path/to/MaaAgentBinary",
		nil,
	)
	defer ctrl.Destroy()
	ctrl.PostConnect().Wait()
	tasker.BindController(ctrl)

	res := maa.NewResource(nil)
	defer res.Destroy()
	res.PostPath("./resource").Wait()
	tasker.BindResource(res)
	if tasker.Inited() {
		fmt.Println("Failed to init MAA.")
		os.Exit(1)
	}

	res.RegisterCustomAction("MyAct", &MyAct{})

	tasker.PostPipeline("Startup")
}

type MyAct struct{}

func (a *MyAct) Run(_ *maa.Context, _ *maa.TaskDetail, _, _, _ string, _ *maa.RecognitionDetail, _ maa.Rect) bool {
	return true
}

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 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

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.

func UnregisterCustomAction added in v1.0.0

func UnregisterCustomAction(name string) bool

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

func UnregisterCustomRecognizer(name string) bool

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.

func Version added in v0.5.0

func Version() string

Version returns the version of the maa framework.

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) Clone added in v1.0.0

func (ctx *Context) Clone() *Context

Clone clones current Context.

func (*Context) GetTaskJob added in v1.0.0

func (ctx *Context) GetTaskJob() TaskJob

GetTaskJob returns current task job.

func (*Context) GetTasker added in v1.0.0

func (ctx *Context) GetTasker() *Tasker

GetTasker return current Tasker.

func (*Context) OverrideNext added in v1.0.0

func (ctx *Context) OverrideNext(name string, nextList []string) bool

OverrideNext overrides the next list of task by name.

func (*Context) OverridePipeline added in v1.0.0

func (ctx *Context) OverridePipeline(override any) bool

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

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 CustomRecognizerResult struct {
	Box    Rect
	Detail string
}

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 J added in v1.0.0

type J map[string]any

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, waitFunc 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 {
	ID           int64
	Name         string
	Recognition  *RecognitionDetail
	Times        uint64
	RunCompleted bool
}

type RecognitionDetail

type RecognitionDetail struct {
	ID         int64
	Name       string
	Algorithm  string
	Hit        bool
	DetailJson string
	Raw        image.Image
	Draws      []image.Image
}

type Rect added in v0.3.0

type Rect struct {
	X, Y, W, H int32
}

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) ClearCustomAction added in v1.0.0

func (r *Resource) ClearCustomAction() bool

ClearCustomAction clears all custom actions registered from the resource.

func (*Resource) ClearCustomRecognizer added in v1.0.0

func (r *Resource) ClearCustomRecognizer() bool

ClearCustomRecognizer clears all custom recognizers registered from the resource.

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) Handle added in v1.0.0

func (r *Resource) Handle() unsafe.Pointer

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.

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

func (r *Resource) UnregisterCustomAction(name string) bool

UnregisterCustomAction unregisters a custom action from the resource.

func (*Resource) UnregisterCustomRecognizer added in v1.0.0

func (r *Resource) UnregisterCustomRecognizer(name string) bool

UnregisterCustomRecognizer unregisters a custom recognizer from 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 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 NewTaskJob(
	id int64,
	statusFunc func(id int64) Status,
	waitFunc func(id int64) Status,
	getTaskDetailFunc func(id int64) *TaskDetail,
) TaskJob

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 NewTasker added in v1.0.0

func NewTasker(callback func(msg, detailsJson string)) *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

func (t *Tasker) BindResource(res *Resource) bool

BindResource binds the tasker to an initialized resource.

func (*Tasker) ClearCache added in v1.0.0

func (t *Tasker) ClearCache() bool

ClearCache clears runtime cache.

func (*Tasker) Destroy added in v1.0.0

func (t *Tasker) Destroy()

Destroy free the tasker.

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

func (t *Tasker) GetResource() *Resource

GetResource returns the resource handle of the tasker.

func (*Tasker) Handle added in v1.0.0

func (t *Tasker) Handle() unsafe.Pointer

Handle returns the tasker handle.

func (*Tasker) Inited added in v1.0.0

func (t *Tasker) Inited() bool

Inited checks if the tasker is initialized.

func (*Tasker) PostAction added in v1.0.0

func (t *Tasker) PostAction(entry string, override ...any) TaskJob

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

func (t *Tasker) PostPipeline(entry string, override ...any) TaskJob

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

func (t *Tasker) PostRecognition(entry string, override ...any) TaskJob

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.

func (*Tasker) PostStop added in v1.0.0

func (t *Tasker) PostStop() bool

PostStop posts a stop signal to the tasker.

func (*Tasker) Running added in v1.0.0

func (t *Tasker) Running() bool

Running checks if the instance running.

func (*Tasker) WaitAll added in v1.0.0

func (t *Tasker) WaitAll()

WaitAll waits for all tasks to complete.

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

Directories

Path Synopsis
examples
internal

Jump to

Keyboard shortcuts

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