Code Monkey home page Code Monkey logo

maaframework.binding.csharp's Introduction

LOGO

MaaFramework.Binding.CSharp

✨ The csharp binding of MaaFramework

💫 A common interoperable API wrapper 💫

license language platform Nuget (with prereleases)

Articles

Get Started

System Requirements

Your computer should meet the minimum system requirements before you run and use MaaFramework.Binding.CSharp, which might run on other platforms or versions not listed here.

OS Version Minimum Requirements / Reason
Windows 10+ Restricted from .NET 7.0
macOS 12+ Restricted from MaaFramework
Linux
Ubuntu 23.10+
libc6 2.38+
and more
  • Architectures: x64, Arm64

Install Dependents

MaaFramework.Binding.CSharp needs the following dependencies installed to run properly.

Platform Package Id Dependent Download
Windows Maa.Framework
Maa.Framework.Binding.Native
Visual C++ Redistributable

Prepare Resources

See MaaFramework document (en-us / zh_cn).

Like this SampleResource in MaaFramework.Binding.CSharp.

Run Code

Pre-work: dotnet add package Maa.Framework; adb connect HOST[:PORT];

using MaaFramework.Binding;

var devices = new MaaToolkit(true).Device.Find();
if (devices.Length < 1)
    throw new InvalidOperationException();

using var maa = new MaaInstance
{
    Controller = devices[0].ToAdbController(),
    Resource = new MaaResource("./SampleResource"),
    DisposeOptions = DisposeOptions.All,
};

if (!maa.Initialized)
    throw new InvalidOperationException();

maa.AppendTask("EmptyTask")
   .Wait()
   .ThrowIfNot(MaaJobStatus.Success);

Console.WriteLine("EmptyTask Completed");

Custom

using MaaFramework.Binding.Buffers;
using MaaFramework.Binding.Custom;

var taskName = "MyCustomTask";
var param = $$"""
{
  "{{taskName}}": {
      "recognition": "Custom",
      "custom_recognition": "MyRec",
      "custom_recognition_param": {
          "my_rec_key": "my_rec_value"
      },
      "action": "Custom",
      "custom_action": "MyAct",
      "custom_action_param": {
          "my_act_key": "my_act_value"
      }
  }
}
""";

maa.Register(new MyRec());
maa.Register(new MyAct());
maa.AppendTask(taskName, param)
    .Wait()
    .ThrowIfNot(MaaJobStatus.Success);

internal sealed class MyRec : IMaaCustomRecognizer
{
    public string Name { get; set; } = nameof(MyRec);

    public bool Analyze(in IMaaSyncContext syncContext, IMaaImageBuffer image, string taskName, string customRecognitionParam, in IMaaRectBuffer outBox, in IMaaStringBuffer outDetail)
    {
        outBox.SetValues(0, 0, 100, 100);
        outDetail.SetValue("Hello World!");
        return true;
    }
}

internal sealed class MyAct : IMaaCustomAction
{
    public string Name { get; set; } = nameof(MyAct);

    public void Abort() { }

    public bool Run(in IMaaSyncContext syncContext, string taskName, string customActionParam, IMaaRectBuffer curBox, string curRecDetail)
    {
        return true;
    }
}

Best Practices

  • MBA BA Assistant
    A BA Assistant based on MAA's new architecture. Image technology + simulation control, no more clicking! Powered by MaaFramework.

  • You can also find more examples in the Unit Tests.

Documentation

We have written detailed documentation comments in source code files.

You can also visit API Reference and Unit Tests for more information.

Contributing

We welcome contributions to the MaaFramework.Binding.CSharp. 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

MaaFramework is open-sourced under the LGPL-3.0 license.

Discussion

  • QQ Group: 595990173

maaframework.binding.csharp's People

Contributors

moomiji avatar neko-para avatar alisaakiron avatar misteo avatar dantmnf avatar dissectum avatar

Stargazers

mutsumi avatar  avatar  avatar  avatar 企鹅2035 avatar  avatar Mayuu酱重症患者 avatar

Watchers

 avatar  avatar

Forkers

dissectum

maaframework.binding.csharp's Issues

Release v2.0 的一些想法

  • 将那一系列像 Flags Enum 实际上又不是的通通拆分
  • windows 平台包
  • 隐式包引用不能正常复制
  • 合并 screencap 和 getImage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.