Skip to content

Commit

Permalink
docs: fix markdown linting Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwlin committed Dec 5, 2024
1 parent e107bd6 commit e461cc1
Show file tree
Hide file tree
Showing 2 changed files with 306 additions and 306 deletions.
307 changes: 153 additions & 154 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
# MaaFramework Golang Binding

<p>
<a href="https://github.com/MaaXYZ/maa-framework-go/blob/main/LICENSE.md">
<img alt="license" src="https://img.shields.io/github/license/MaaXYZ/maa-framework-go">
</a>
<a href="https://pkg.go.dev/github.com/MaaXYZ/maa-framework-go">
<img alt="go reference" src="https://pkg.go.dev/badge/github.com/MaaXYZ/maa-framework-go">
</a>
<a href="https://github.com/MaaXYZ/maa-framework-go/blob/main/LICENSE.md">
<img alt="license" src="https://img.shields.io/github/license/MaaXYZ/maa-framework-go">
</a>
<a href="https://pkg.go.dev/github.com/MaaXYZ/maa-framework-go">
<img alt="go reference" src="https://pkg.go.dev/badge/github.com/MaaXYZ/maa-framework-go">
</a>
<a href="https://github.com/MaaXYZ/MaaFramework/releases/tag/v2.2.2">
<img alt="maa framework" src="https://img.shields.io/badge/MaaFramework-v2.2.2-blue">
</a>
</p>

English | [简体中文](README_zh.md)


This is the Go binding for [MaaFramework](https://github.com/MaaXYZ/MaaFramework), providing Go developers with a simple and effective way to use MaaFramework's features within their Go applications.

> No Cgo required!
Expand Down Expand Up @@ -48,7 +47,7 @@ Then, you can use the functionalities provided by MaaFramework. For detailed usa
>
> 1. The program's working directory contains the MaaFramework dynamic libraries.
> 2. Environment variables (such as LD_LIBRARY_PATH or PATH) are set to include the path to the dynamic libraries.
>
>
> Otherwise, the program may not run correctly.
## Documentation
Expand Down Expand Up @@ -77,42 +76,42 @@ Here is a basic example to get you started:
package main

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

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

device := toolkit.FindAdbDevices()[0]
ctrl := maa.NewAdbController(
device.AdbPath,
device.Address,
device.ScreencapMethod,
device.InputMethod,
device.Config,
"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.Initialized() {
fmt.Println("Failed to init MAA.")
os.Exit(1)
}

detail := tasker.PostPipeline("Startup").Wait().GetDetail()
fmt.Println(detail)
toolkit := maa.NewToolkit()
toolkit.ConfigInitOption("./", "{}")
tasker := maa.NewTasker(nil)
defer tasker.Destroy()

device := toolkit.FindAdbDevices()[0]
ctrl := maa.NewAdbController(
device.AdbPath,
device.Address,
device.ScreencapMethod,
device.InputMethod,
device.Config,
"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.Initialized() {
fmt.Println("Failed to init MAA.")
os.Exit(1)
}

detail := tasker.PostPipeline("Startup").Wait().GetDetail()
fmt.Println(detail)
}

```
Expand All @@ -127,78 +126,78 @@ Here is a basic example to implement your custom recognition:
package main

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

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

device := toolkit.FindAdbDevices()[0]
ctrl := maa.NewAdbController(
device.AdbPath,
device.Address,
device.ScreencapMethod,
device.InputMethod,
device.Config,
"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.Initialized() {
fmt.Println("Failed to init MAA.")
os.Exit(1)
}

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

detail := tasker.PostPipeline("Startup").Wait().GetDetail()
fmt.Println(detail)
toolkit := maa.NewToolkit()
toolkit.ConfigInitOption("./", "{}")
tasker := maa.NewTasker(nil)
defer tasker.Destroy()

device := toolkit.FindAdbDevices()[0]
ctrl := maa.NewAdbController(
device.AdbPath,
device.Address,
device.ScreencapMethod,
device.InputMethod,
device.Config,
"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.Initialized() {
fmt.Println("Failed to init MAA.")
os.Exit(1)
}

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

detail := tasker.PostPipeline("Startup").Wait().GetDetail()
fmt.Println(detail)
}

type MyRec struct{}

func (r *MyRec) Run(ctx *maa.Context, arg *maa.CustomRecognitionArg) (maa.CustomRecognitionResult, bool) {
ctx.RunRecognition("MyCustomOCR", arg.Img, maa.J{
"MyCustomOCR": maa.J{
"roi": []int{100, 100, 200, 300},
},
})

ctx.OverridePipeline(maa.J{
"MyCustomOCR": maa.J{
"roi": []int{1, 1, 114, 514},
},
})

newContext := ctx.Clone()
newContext.OverridePipeline(maa.J{
"MyCustomOCR": maa.J{
"roi": []int{100, 200, 300, 400},
},
})
newContext.RunPipeline("MyCustomOCR", arg.Img)

clickJob := ctx.GetTasker().GetController().PostClick(10, 20)
clickJob.Wait()

ctx.OverrideNext(arg.CurrentTaskName, []string{"TaskA", "TaskB"})

return maa.CustomRecognitionResult{
Box: maa.Rect{0, 0, 100, 100},
Detail: "Hello World!",
}, true
ctx.RunRecognition("MyCustomOCR", arg.Img, maa.J{
"MyCustomOCR": maa.J{
"roi": []int{100, 100, 200, 300},
},
})

ctx.OverridePipeline(maa.J{
"MyCustomOCR": maa.J{
"roi": []int{1, 1, 114, 514},
},
})

newContext := ctx.Clone()
newContext.OverridePipeline(maa.J{
"MyCustomOCR": maa.J{
"roi": []int{100, 200, 300, 400},
},
})
newContext.RunPipeline("MyCustomOCR", arg.Img)

clickJob := ctx.GetTasker().GetController().PostClick(10, 20)
clickJob.Wait()

ctx.OverrideNext(arg.CurrentTaskName, []string{"TaskA", "TaskB"})

return maa.CustomRecognitionResult{
Box: maa.Rect{0, 0, 100, 100},
Detail: "Hello World!",
}, true
}

```
Expand All @@ -213,50 +212,50 @@ Here is a basic example to implement your custom action:
package main

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

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

device := toolkit.FindAdbDevices()[0]
ctrl := maa.NewAdbController(
device.AdbPath,
device.Address,
device.ScreencapMethod,
device.InputMethod,
device.Config,
"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.Initialized() {
fmt.Println("Failed to init MAA.")
os.Exit(1)
}

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

detail := tasker.PostPipeline("Startup").Wait().GetDetail()
fmt.Println(detail)
toolkit := maa.NewToolkit()
toolkit.ConfigInitOption("./", "{}")
tasker := maa.NewTasker(nil)
defer tasker.Destroy()

device := toolkit.FindAdbDevices()[0]
ctrl := maa.NewAdbController(
device.AdbPath,
device.Address,
device.ScreencapMethod,
device.InputMethod,
device.Config,
"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.Initialized() {
fmt.Println("Failed to init MAA.")
os.Exit(1)
}

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

detail := tasker.PostPipeline("Startup").Wait().GetDetail()
fmt.Println(detail)
}

type MyAct struct{}

func (a *MyAct) Run(_ *maa.Context, _ *maa.CustomActionArg) bool {
return true
return true
}

```
Expand All @@ -271,28 +270,28 @@ Here is a basic example of using PI CLI:
package main

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

func main() {
toolkit := maa.NewToolkit()
toolkit.RegisterPICustomAction(0, "MyAct", &MyAct{})
toolkit.RunCli(0, "./resource", "./", false, nil)
toolkit := maa.NewToolkit()
toolkit.RegisterPICustomAction(0, "MyAct", &MyAct{})
toolkit.RunCli(0, "./resource", "./", false, nil)
}

type MyAct struct{}

func (m MyAct) Run(ctx *maa.Context, arg *maa.CustomActionArg) bool {
ctx.OverrideNext(arg.CurrentTaskName, []string{"TaskA", "TaskB"})
ctx.OverrideNext(arg.CurrentTaskName, []string{"TaskA", "TaskB"})

img := ctx.GetTasker().GetController().CacheImage()
ctx.GetTasker().GetController().PostClick(100, 100).Wait()
img := ctx.GetTasker().GetController().CacheImage()
ctx.GetTasker().GetController().PostClick(100, 100).Wait()

ctx.RunRecognition("Cat", img, maa.J{
"recognition": "OCR",
"expected": "cat",
})
return true
ctx.RunRecognition("Cat", img, maa.J{
"recognition": "OCR",
"expected": "cat",
})
return true
}

```
Expand All @@ -307,4 +306,4 @@ This project is licensed under the LGPL-3.0 License. See the [LICENSE](https://g

## Discussion

QQ Group: 595990173
QQ Group: 595990173
Loading

0 comments on commit e461cc1

Please sign in to comment.