Skip to content

terwer/autojs6-dev-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

40 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AutoJS6 Visual Development Toolkit

English | ็ฎ€ไฝ“ไธญๆ–‡

๐ŸŽฏ A development toolkit for AutoJS6 script developers, with visual screenshot analysis, UI widget parsing, image matching preview, and AutoJS6 script code generation.

Choose the edition that fits your platform strategy
autojs6-dev-tools is the Windows-native edition, optimized for a performance-first Windows experience.
For the Cross-platform edition, see autojs6-dev-tools-plus.
Both projects are original works that I design and maintain as part of the same AutoJS6 toolkit family.

Image recognition takes 20 tries to work? Breaks on different devices?
Use this tool: Real-time match preview โ€ข Visual threshold and region adjustment โ€ข Auto-generate AutoJS6 code

.NET WinUI 3 License


โšก See the Toolkit in Action

Bring screenshot analysis, widget inspection, and AutoJS6 code generation into one native Windows workbench. Tune match regions visually, validate selectors against the current UI tree, and export runnable code without bouncing between crop tools, terminals, and repeated device-side trial and error.

Animated demo of the AutoJS6 Visual Workbench switching between image mode and control mode

Live template cropping ยท Threshold tuning ยท Widget boundary inspection ยท AutoJS6-ready code generation

๐Ÿ–ฅ๏ธ Two Focused Workspaces

Image mode workspace for cropping templates, tuning threshold, and previewing OpenCV matches
Image Mode ยท Crop templates, preview OpenCV matches, and export images.findImage()-based AutoJS6 flows.
Control mode workspace for parsing UI tree, highlighting widgets, and generating UiSelector code
Control Mode ยท Inspect the Android UI hierarchy, highlight widget bounds, and generate selector-based AutoJS6 actions.

๐Ÿ˜ซ The Pain You Know Too Well

Developing AutoJS6 scripts without this tool:

  1. ๐Ÿ“ธ Screenshot โ†’ Manually crop template โ†’ Save โ†’ Write code โ†’ Run on device
  2. ๐Ÿ“ Guess coordinates (x: 500? 520? 540?) โ†’ Write code โ†’ Run on device
  3. โŒ Template not found โ†’ Adjust crop by 2 pixels โ†’ Run again
  4. ๐Ÿ”„ Repeat 20 times until it works
  5. ๐Ÿ“ฑ Test on another device โ†’ Different resolution โ†’ Start over
  6. ๐Ÿค” Threshold 0.8 or 0.85? โ†’ Try one by one on real device
  7. ๐ŸŒฒ Need resource-id? โ†’ Manually search through 5000 UI nodes
  8. ๐Ÿ’ฅ Click missed by 10 pixels โ†’ Recalculate offset โ†’ Run again

Hours wasted. Every. Single. Day.


โœจ What This Tool Actually Does

See template matching results BEFORE running on device:

  • Drag to crop template โ†’ Instantly see match confidence (0.95? 0.62?)
  • Adjust threshold slider โ†’ Watch matches appear/disappear in real-time
  • Wrong crop? Adjust 2 pixels โ†’ See result immediately
  • No more "run โ†’ fail โ†’ adjust โ†’ run" loops

Pick coordinates with mouse, not guesswork:

  • Hover over screenshot โ†’ See exact pixel coordinates (x: 523, y: 187)
  • Click to mark โ†’ Coordinates copied to clipboard
  • Drag rectangle โ†’ Get region [x, y, w, h] automatically
  • No more "let me try x+10... no wait, x+15..."

Generate AutoJS6 code automatically:

  • Select template โ†’ Click "Generate Code" โ†’ Get complete script
  • Image mode: images.findImage() with correct threshold and region
  • Widget mode: id().text().findOne() with fallback selectors
  • Copy-paste ready, no manual typing

Test on multiple resolutions without real devices:

  • Load screenshots from 3 devices โ†’ Test template on all
  • See which resolution fails โ†’ Adjust crop once โ†’ Works everywhere
  • No more "works on my phone but not on user's phone"

๐Ÿ’ก Who Needs This?

You need this if you:

  • โœ… Spend >30 minutes per day cropping screenshots and adjusting coordinates
  • โœ… Test scripts on multiple Android devices with different resolutions
  • โœ… Use image recognition features frequently
  • โœ… Need to manually search UI tree for widget attributes
  • โœ… Want to preview matching results without running on device

You DON'T need this if:

  • โŒ You only use simple fixed-coordinate clicks
  • โŒ You never use image matching or widget selectors
  • โŒ You enjoy manually debugging 20 times per feature

๐Ÿš€ Quick Start

Prerequisites

  • ๐Ÿ’ป OS: Windows 10/11 (Build 22621.0+)
  • โš™๏ธ Runtime: .NET 8 SDK
  • ๐Ÿ› ๏ธ IDE: Visual Studio 2022/2026 with WinUI 3 workload
  • ๐Ÿ“ฑ Tools: Android Debug Bridge (ADB) in PATH

1๏ธโƒฃ Clone the Repository

git clone https://github.com/yourusername/autojs6-dev-tools.git
cd autojs6-dev-tools

2๏ธโƒฃ Install Dependencies

# Restore NuGet packages
dotnet restore

3๏ธโƒฃ Configure Environment Variables

Edit AGENTS.md to set your local paths:

YXS_DAY_TASK_ROOT="C:\path\to\your\yxs-day-task"
AUTOJS6_DOCS_ROOT="C:\path\to\AutoJs6-Documentation"
AUTOJS6_SOURCE_ROOT="C:\path\to\AutoJs6"

4๏ธโƒฃ Build and Run

# Restore solution packages
dotnet restore autojs6-dev-tools.slnx

# Build solution
dotnet build autojs6-dev-tools.slnx

# Run application
dotnet run --project App/App.csproj

Or open autojs6-dev-tools.slnx in Visual Studio and press F5.


โœจ Features

๐Ÿ–ผ๏ธ Image Processing Engine (Pixel-Level)

  • ๐Ÿ“ธ Real-Time Screenshot Capture: Pull device screenshots via ADB with one click
  • โœ‚๏ธ Interactive Cropping: Drag vertices/edges to adjust, Shift to lock aspect ratio
  • ๐ŸŽฏ Pixel Coordinate Picker: Mouse hover shows exact coordinates, Ctrl for crosshair lock
  • ๐Ÿ” OpenCV Template Matching: TM_CCOEFF_NORMED algorithm with adjustable threshold (0.50-0.95)
  • ๐Ÿ’พ Template Export: Save cropped regions as PNG with offset metadata

๐ŸŒฒ UI Layer Analysis Engine (Widget-Level)

  • ๐Ÿ“ฑ Android UI Tree Parsing: Pull and parse uiautomator dump data
  • ๐Ÿงน Smart Layout Filtering: Automatically remove 70%+ redundant layout containers
  • ๐ŸŽจ Widget Boundary Rendering: Color-coded by type (Blue=Text, Green=Button, Orange=Image)
  • ๐Ÿ”— Bidirectional Sync: Click TreeView โ†’ highlight canvas, click canvas โ†’ expand TreeView
  • ๐Ÿ“‹ Property Panel: One-click copy coordinates, text, or XPath expressions

๐ŸŽจ High-Performance Canvas

  • โšก 60 FPS Rendering: Win2D GPU-accelerated dual-layer architecture
  • ๐Ÿ” Zoom & Pan: Mouse wheel zoom (10%-500%, cursor-centered), drag to pan with inertia
  • ๐Ÿ”„ Rotation Support: 90ยฐ step rotation with coordinate system preservation
  • ๐Ÿ“ Auxiliary Tools: Pixel ruler, 10x10 grid, crosshair lock

๐Ÿค– AutoJS6 Code Generator

Image Mode (Pixel-based matching)

// Auto-generated AutoJS6 code
requestScreenCapture();
var template = images.read("./assets/login_button.png");
var result = images.findImage(screen, template, {
    threshold: 0.85,
    region: [100, 200, 300, 400]
});
if (result) {
    click(result.x + 150, result.y + 25);
    log("Clicked login button");
}
template.recycle();

Widget Mode (Selector-based)

// Auto-generated AutoJS6 code
var widget = id("com.example:id/login_button").findOne();
if (!widget) widget = text("Login").findOne();
if (!widget) widget = desc("Login Button").findOne();
if (widget) {
    widget.click();
    log("Clicked login button");
}

โšก Real-Time Match Testing

  • ๐ŸŽš๏ธ Live Threshold Adjustment: Slider (0.50-0.95) with instant visual feedback
  • โœ… UiSelector Validation: Test selectors against current UI tree
  • ๐Ÿ“ Coordinate Alignment Check: Verify widget bounds match screenshot pixels
  • ๐Ÿ“Š Batch Testing: Load multiple templates, generate summary report

๐Ÿ“ Project Structure

autojs6-dev-tools/
โ”œโ”€โ”€ App/                        # WinUI 3 desktop application
โ”‚   โ”œโ”€โ”€ Views/                  # Pages and custom controls
โ”‚   โ”œโ”€โ”€ ViewModels/             # MVVM view models
โ”‚   โ”œโ”€โ”€ Services/               # App-layer orchestration services
โ”‚   โ”œโ”€โ”€ Models/                 # UI-facing models
โ”‚   โ”œโ”€โ”€ Resources/              # Styles and resource dictionaries
โ”‚   โ”œโ”€โ”€ CodeTemplates/          # AutoJS6 code generation templates
โ”‚   โ””โ”€โ”€ App.csproj
โ”œโ”€โ”€ Core/                       # Pure business logic (no UI dependencies)
โ”‚   โ”œโ”€โ”€ Abstractions/           # Service interfaces
โ”‚   โ”œโ”€โ”€ Models/                 # Domain models
โ”‚   โ”œโ”€โ”€ Services/               # Core business services
โ”‚   โ”œโ”€โ”€ Helpers/                # Utility classes
โ”‚   โ””โ”€โ”€ Core.csproj
โ”œโ”€โ”€ Infrastructure/             # External dependency adapters
โ”‚   โ”œโ”€โ”€ Adb/                    # ADB communication
โ”‚   โ”œโ”€โ”€ Imaging/                # OpenCV / imaging wrappers
โ”‚   โ””โ”€โ”€ Infrastructure.csproj
โ”œโ”€โ”€ App.Tests/                  # UI/app-level tests
โ”œโ”€โ”€ Core.Tests/                 # Core unit tests
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ images/                 # README screenshots and demo assets
โ”œโ”€โ”€ openspec/                   # OpenSpec change proposals
โ”œโ”€โ”€ AGENTS.md                   # Core design principles (AI agent context)
โ”œโ”€โ”€ autojs6-dev-tools.slnx      # Solution entry
โ””โ”€โ”€ README.md                   # This file

๐Ÿ—๏ธ Architecture Principles

๐Ÿ”€ Dual-Engine Independence (Strict Isolation)

  • ๐Ÿ–ผ๏ธ Image Engine: Pixel/bitmap โ†’ absolute pixel coordinates (x, y, w, h)
  • ๐ŸŒฒ UI Engine: Widget tree โ†’ UiSelector chains (id().text().findOne())
  • ๐Ÿšซ Zero Coupling: Data sources, processing pipelines, rendering logic, and code generation paths are completely decoupled

โฌ‡๏ธ Unidirectional Dependency

App โ†’ Infrastructure โ†’ Core โ† Infrastructure
  • ๐ŸŽฏ Core: Pure business logic, no UI dependencies, independently testable
  • ๐Ÿ”Œ Infrastructure: External dependency wrappers (SharpAdbClient, OpenCvSharp4)
  • ๐ŸŽจ App: UI and MVVM only

โšก Async-First Architecture

  • All I/O operations (ADB, OpenCV, XML parsing, texture upload) use async/await
  • UI thread never blocked
  • Background operations with CancellationToken support

๐Ÿ› ๏ธ Key Technologies

Component Technology Purpose
๐ŸŽจ UI Framework WinUI 3 + Windows App SDK 1.5+ Native Windows desktop UI
๐Ÿ–ผ๏ธ Rendering Microsoft.Graphics.Win2D 60 FPS GPU-accelerated canvas
๐Ÿ” Image Processing OpenCvSharp4.Windows + SixLabors.ImageSharp Template matching and image manipulation
๐Ÿ“ฑ ADB Communication SharpAdbClient Android device control
๐Ÿ”— MVVM CommunityToolkit.Mvvm View model binding and commands
๐Ÿ—๏ธ Architecture Clean Architecture Layered separation of concerns

๐Ÿ‘จโ€๐Ÿ’ป Development Workflow

๐Ÿ“– Before Implementation

  1. Read AGENTS.md for core design principles
  2. Read openspec/project.md for development checklist
  3. Analyze existing cmd scripts in $YXS_DAY_TASK_ROOT
  4. Review AutoJS6 documentation and source code

๐Ÿ’ป During Implementation

  • โœ… Maintain dual-engine independence
  • โœ… Follow unidirectional dependency rules
  • โœ… Use async/await for all I/O operations
  • โœ… Keep modules under 512 lines
  • โœ… Write tests for Core layer

โœ”๏ธ Before Commit

  • โœ… Verify project layer dependencies (App โ†’ Infrastructure โ†’ Core)
  • โœ… Verify dual-engine isolation
  • โœ… Verify async architecture
  • โœ… Verify 60 FPS rendering performance
  • โœ… Run unit tests

โš ๏ธ AutoJS6 Code Generation Constraints

Generated code must comply with AutoJS6 runtime constraints:

๐Ÿ› Rhino Engine Limitations

// โŒ WRONG: const/let in loop body (Rhino bug - variable won't rebind)
while (true) {
    const result = computeSomething();
    process(result);  // result keeps first iteration value!
}

// โœ… CORRECT: Use var in loop body
while (true) {
    var result = computeSomething();
    process(result);  // result correctly updates each iteration
}

๐Ÿ’พ OOM Prevention

  • ๐Ÿ“ธ Single screenshot per iteration: Never call captureScreen() multiple times in one loop
  • ๐ŸŽฏ Minimize scene detection scope: Don't scan all templates every iteration
  • ๐Ÿ“ Prefer region-based matching: Use region: [x, y, w, h] instead of full-screen
  • โ™ป๏ธ Recycle ImageWrapper objects: Call .recycle() immediately after use

โœ‚๏ธ Template Cropping Rules

โœ… Include: Text, icons, fixed borders
โŒ Exclude: Red dots, numbers, countdowns, dynamic values


๐Ÿค Contributing

We welcome contributions! Please:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch (git checkout -b feature/amazing-feature)
  3. ๐Ÿ“– Read AGENTS.md and openspec/project.md thoroughly
  4. ๐Ÿ—๏ธ Follow the architecture principles
  5. โœ… Write tests for Core layer changes
  6. ๐Ÿ’ฌ Commit with clear messages (git commit -m 'add amazing feature')
  7. ๐Ÿš€ Push to your branch (git push origin feature/amazing-feature)
  8. ๐Ÿ”€ Open a Pull Request

๐ŸŽฏ Reference Projects

This toolkit is designed to serve AutoJS6 automation projects, particularly:

  • ๐ŸŽฎ yxs-day-task: Hero Kill daily task automation (primary beneficiary)

๐Ÿ“š Documentation

  • ๐Ÿ“˜ AGENTS.md: Core design principles and constraints (read first)
  • ๐Ÿ“— openspec/project.md: Development checklist and verification rules
  • ๐Ÿ“‚ openspec/changes/: OpenSpec change proposals

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE.txt file for details.


๐Ÿ™ Acknowledgments

  • AutoJS6 - Android automation framework
  • WinUI 3 - Modern Windows UI framework
  • Win2D - GPU-accelerated 2D graphics
  • OpenCvSharp - OpenCV wrapper for .NET

๐Ÿ’ฌ Support


โ˜• Buy Me a Coffee

If this tool saves you hours of tedious work, consider buying me a coffee! Your support keeps this project alive and helps me dedicate more time to adding new features.

Support via:

WeChat Pay
WeChat Pay

Scan to donate
Alipay
Alipay

Scan to donate
็ˆฑๅ‘็”ต
็ˆฑๅ‘็”ต (afdian)
Support on ็ˆฑๅ‘็”ต
Monthly sponsorship

Your support enables:

  • โšก Continuous development and maintenance
  • ๐ŸŽฏ New features based on community feedback
  • ๐Ÿ“š Professional documentation and video tutorials
  • ๐Ÿ› ๏ธ Long-term stability and updates

Sponsors get:

  • ๐ŸŒŸ Name listed in project credits
  • ๐Ÿ’ฌ Direct communication channel
  • ๐Ÿš€ Early access to new features

Every contribution matters. Thank you! ๐Ÿ™

๐Ÿ’– Sponsors

Thanks to the following sponsors for their generous support:


Built with โค๏ธ for AutoJS6 developers

About

โš ๏ธ Under Active Development - ๐ŸŽฏ A development toolkit for AutoJS6 script developers, with visual screenshot analysis, UI widget parsing, image matching preview, and AutoJS6 script code generation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors