### Install Application Source: https://autogo.cc/#/index_/API/app Installs an application from an APK file. This function also supports the installation of xapk files. ```Go app.Install("/sdcard/app.apk") ``` -------------------------------- ### Start Activity with Intent Options Source: https://autogo.cc/#/index_/API/app Constructs an Intent based on the provided `IntentOptions` and starts the corresponding Activity. `IntentOptions` allows specifying action, type, data, category, package name, extras, and flags. ```Go app.StartActivity(app.IntentOptions{ Action: "SEND", Type: "text/plain", Data: "file:///sdcard/1.txt", }) ``` -------------------------------- ### Start Service with Intent Options Source: https://autogo.cc/#/index_/API/app Constructs an Intent based on `IntentOptions` and starts the associated service. This is used to initiate background operations provided by other applications. ```Go app.StartService(options) ``` -------------------------------- ### Get Application List Source: https://autogo.cc/#/index_/API/app Retrieves a list of all applications installed on the device. Users can choose to include system applications in the list by setting the `includeSystemApps` parameter to true. ```Go list := app.GetList(true) ``` -------------------------------- ### Check if Application is Installed Source: https://autogo.cc/#/index_/API/app Determines whether a specific application is currently installed on the device. It returns a boolean value indicating the installation status. ```Go installed := app.IsInstalled("com.tencent.mm") ``` -------------------------------- ### Full Example: AutoGo Plugin Usage in Go Source: https://autogo.cc/#/index_/API/plugin A comprehensive example demonstrating loading an APK, creating an instance, performing OCR recognition, saving data, and loading resources using the AutoGo plugin system. ```go package main import ( "fmt" "github.com/Dasongzi1366/AutoGo/plugin" "github.com/Dasongzi1366/AutoGo/images" ) func main() { // 加载APK插件 cl := plugin.LoadApk("/data/local/tmp/assets/ocr_plugin.apk") if cl == nil { fmt.Println("加载APK失败") return } defer cl.Release() // 创建OCR引擎实例 engine, err := cl.NewInstance("com.ddddocr.OCREngine") if err != nil { fmt.Printf("创建实例失败: %v\n", err) return } defer engine.Release() // 截取屏幕 img := images.CaptureScreen(0, 0, 0, 0, 0) // 调用OCR识别(图像自动转为Bitmap) result, err := engine.CallString("recognition", img) if err != nil { fmt.Printf("识别失败: %v\n", err) return } fmt.Printf("识别结果: %s\n", result) // 调用需要Context的方法 err = engine.CallVoid("saveToCache", plugin.Context{}, "data.txt") if err != nil { fmt.Printf("保存失败: %v\n", err) } // 使用AssetManager加载APK中的资源 assetMgr := plugin.NewAssetManager() resourceData, err := engine.CallString("loadResource", assetMgr, "config.json") if err != nil { fmt.Printf("加载资源失败: %v\n", err) } else { fmt.Printf("资源内容: %s\n", resourceData) } } ``` -------------------------------- ### Get Application Version Source: https://autogo.cc/#/index_/API/app Fetches the version number of a specified application. The function requires the application's package name as input. ```Go version := app.GetVersion("com.tencent.mm") ``` -------------------------------- ### Example: Full Console Configuration and Logging (Go) Source: https://autogo.cc/#/index_/API/console Demonstrates creating, configuring, and continuously logging to a console instance. It sets various properties like position, size, and colors, then prints time updates in a loop. ```Go // 创建并配置控制台 c := console.New() c.SetWindowPosition(50, 50) c.SetWindowSize(700, 500) c.SetWindowColor("#1E1F22") c.SetTextColor("#00FF00") c.SetTextSize(45) // 打印日志 c.Println("控制台已就绪") for { c.Println("当前时间:", time.Now().Format("2006-01-02 15:04:05")) utils.Sleep(1000) } ``` -------------------------------- ### Set Script Boot Start - Go Source: https://autogo.cc/#/index_/API/system Configures the script to automatically run on system boot. This function requires root privileges and is part of the 'system' package. ```go system.SetBootStart(true) ``` -------------------------------- ### Get Application Name Source: https://autogo.cc/#/index_/API/app Fetches the display name of an application given its package name. This function takes a single string argument representing the package name. ```Go name := app.GetName("bin.mt.plus") ``` -------------------------------- ### Get Network Information Source: https://autogo.cc/#/index_/API/device Retrieves network-related information from the device. This includes the device's local IP address. ```go ip := device.GetIp() ``` -------------------------------- ### Get Memory Information Source: https://autogo.cc/#/index_/API/device Retrieves the total and available memory of the device in kilobytes (KB). ```go totalMem := device.GetTotalMem() availMem := device.GetAvailMem() ``` -------------------------------- ### Get Current Package Name Source: https://autogo.cc/#/index_/API/app Retrieves the package name of the application currently running on the screen. This function does not require any input parameters. ```Go packageName := app.CurrentPackage() ``` -------------------------------- ### Get Default Browser Package Source: https://autogo.cc/#/index_/API/app Retrieves the package name of the default web browser set on the device. This function does not require any input parameters. ```Go packageName := app.GetBrowserPackage() ``` -------------------------------- ### Get Application Icon Source: https://autogo.cc/#/index_/API/app Retrieves the icon of an application based on its package name. The function returns the icon data, which can then be used for display purposes. ```Go data := app.GetIcon("com.tencent.mm") ``` -------------------------------- ### Get Battery Information Source: https://autogo.cc/#/index_/API/device Retrieves the current battery percentage and status. The status indicates whether the battery is charging, full, or not charging. ```go battery := device.GetBattery() status := device.GetBatteryStatus() ``` -------------------------------- ### Execute Shell Command and Get Output (Go) Source: https://autogo.cc/#/index_/API/utils Executes a given shell command and returns its standard output. This function is useful for interacting with the operating system's command line from within the Go program. It takes a single string argument representing the command to execute. ```Go output := utils.Shell("ls -l") fmt.Println("Command Output:", output) ``` -------------------------------- ### Get Device Identifiers Source: https://autogo.cc/#/index_/API/device Retrieves unique identifiers for the device. This includes the IMEI, Android ID, and MAC addresses for Wi-Fi and WLAN interfaces. ```go imei := device.GetImei() androidId := device.GetAndroidId() wifiMac := device.GetWifiMac() wlanMac := device.GetWlanMac() ``` -------------------------------- ### Set Console Window Background Color (Go) Source: https://autogo.cc/#/index_/API/console Sets the background color of the console window. The color is specified as a hexadecimal string, for example, "#1E1F22". ```Go c.SetWindowColor("#1E1F22") ``` -------------------------------- ### Get Display Information Source: https://autogo.cc/#/index_/API/device Retrieves resolution information for a specified screen. It takes a displayId as input (0 for the main screen) and returns the width, height, DPI, and rotation of the screen. ```go width, height, dpi, rotation := device.GetDisplayInfo(0) fmt.Printf("屏幕分辨率: %dx%d, DPI: %d, 旋转角度: %d\n", width, height, dpi, rotation) ``` -------------------------------- ### GET Request Source: https://autogo.cc/#/index_/API/https Sends an HTTP GET request to the specified URL and returns the response status code and data. Supports setting a timeout. ```APIDOC ## GET / ### Description Sends an HTTP GET request to the specified URL and returns the response status code and data. Supports setting a timeout. ### Method GET ### Endpoint `/` ### Parameters #### Query Parameters - **url** (string) - Required - The URL to send the GET request to. - **timeout** (int) - Optional - The request timeout in milliseconds. If 0, no timeout is set. ### Request Example ```lua code, data := https.Get("https://example.com", 5000) if code == 200 { fmt.Println("Request successful:", string(data)) } else { fmt.Println("Request failed, status code:", code) } ``` ### Response #### Success Response (200) - **code** (int) - The HTTP status code of the response. - **data** ([]byte) - The response body as a byte slice. #### Response Example ```json { "code": 200, "data": "..." } ``` ``` -------------------------------- ### Initialize Project and Run Basic Automation (Go) Source: https://autogo.cc/#/index_/ This snippet demonstrates how to initialize an AutoGo project and execute a basic automation command. It requires the AutoGo SDK and Go environment. The code navigates the user to the home screen of an Android device. ```go package main import "github.com/Dasongzi1366/AutoGo/motion" func main() { motion.Home(0) // 回到主界面 } ``` -------------------------------- ### Show Console Window (Go) Source: https://autogo.cc/#/index_/API/console Makes the console window visible. Call this after configuring the console to display it to the user. ```Go c.Show() ``` -------------------------------- ### Get Process CPU Usage - Go Source: https://autogo.cc/#/index_/API/system Retrieves the CPU usage percentage of a specified process. If the PID is 0, it fetches the CPU usage of the current process. Requires the 'system' package. ```go cpuUsage := system.GetCpuUsage(12345) fmt.Println("CPU Usage (%):", cpuUsage) ``` -------------------------------- ### Open Application Settings Source: https://autogo.cc/#/index_/API/app Opens the settings (details) page for a specific application. This is useful for managing app permissions or other configurations. ```Go success := app.OpenSetting("com.tencent.mm") ``` -------------------------------- ### vdisplay - Get Display ID Source: https://autogo.cc/#/index_/API/vdisplay 获取已创建虚拟屏幕的唯一标识符(ID)。 ```APIDOC ## GET /vdisplay/{displayId}/id ### Description Retrieves the unique ID of the virtual display. ### Method GET ### Endpoint /vdisplay/{displayId}/id ### Parameters #### Path Parameters - **displayId** (int) - Required - The ID of the virtual display. ### Response #### Success Response (200) - **display_id** (int) - The ID of the virtual display. #### Response Example ```json { "display_id": 123 } ``` ``` -------------------------------- ### Pixel - Go: Get pixel color value Source: https://autogo.cc/#/index_/API/images 获取指定坐标点 (x, y) 的颜色值。支持指定屏幕ID。返回值为该坐标点的颜色。 ```Go color := images.Pixel(100, 200, 0) ``` -------------------------------- ### Create New Console Instance (Go) Source: https://autogo.cc/#/index_/API/console Creates a new console instance. This function initializes a new console object and returns a pointer to it. It's the first step to interact with the console functionalities. ```Go c := console.New() ``` -------------------------------- ### Launch Application Source: https://autogo.cc/#/index_/API/app Launches an application using its package name. It supports specifying the package name directly or in a 'packageName/className' format. An optional display ID for the screen can also be provided. ```Go success := app.Launch("com.tencent.mm", 0) ``` -------------------------------- ### Get Screen State Source: https://autogo.cc/#/index_/API/device Checks the current state of the device's screen. It can determine if the screen is on and if it is unlocked. ```go isOn := device.IsScreenOn() isUnlock := device.IsScreenUnlock() ``` -------------------------------- ### PowerDialog Source: https://autogo.cc/#/index_/API/motion Pops up the power menu. ```APIDOC ## PowerDialog ### Description Pops up the power menu. ### Method `motion.PowerDialog()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python motion.PowerDialog() ``` ### Response #### Success Response (200) Operation successful. #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### Get Screen Brightness Source: https://autogo.cc/#/index_/API/device Retrieves the current screen brightness level. The value ranges from 0 to 255. ```go brightness := device.GetBrightness() ``` -------------------------------- ### Clear Console Content (Go) Source: https://autogo.cc/#/index_/API/console Clears all content from the console. This is useful for resetting the console display or starting a new log session. ```Go c.Clear() ``` -------------------------------- ### View File with Application Source: https://autogo.cc/#/index_/API/app Opens a specified file using another application capable of viewing it. If the file does not exist, the behavior is determined by the application used for viewing. ```Go app.ViewFile("/sdcard/example.txt") ``` -------------------------------- ### Get All Children of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves all direct child UiObjects of the current UiObject. This method returns a slice of `*UiObject`. It does not have external dependencies. ```Go children := uiObject.GetChildren() for index, child := range children { fmt.Printf("子控件 %d: %v\n", index+1, child) } ``` -------------------------------- ### 显示HUD - Go Source: https://autogo.cc/#/index_/API/hud 使用`Show()`方法使HUD变得可见。此方法返回HUD实例的指针,支持链式调用。 ```Go h.Show() ``` -------------------------------- ### QuickSettings Source: https://autogo.cc/#/index_/API/motion Expands the notification shade to show quick settings. ```APIDOC ## QuickSettings ### Description Expands the notification shade to show quick settings. ### Method `motion.QuickSettings()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python motion.QuickSettings() ``` ### Response #### Success Response (200) Operation successful. #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### Get Parent of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the parent UiObject of the current UiObject. This method returns a pointer to the parent UiObject. It does not have external dependencies. ```Go parent := uiObject.GetParent() fmt.Println("控件的父控件:", parent) ``` -------------------------------- ### Open URL in Browser Source: https://autogo.cc/#/index_/API/app Opens a given URL in the device's default web browser. The function takes the URL as a string argument. ```Go app.OpenUrl("https://example.com") ``` -------------------------------- ### 创建新的HUD实例 - Go Source: https://autogo.cc/#/index_/API/hud 使用`hud.New()`函数创建一个新的HUD实例。此函数不接受任何参数,并返回一个HUD实例的指针。这是使用HUD功能的第一步。 ```Go h := hud.New() ``` -------------------------------- ### Get Current Activity Name Source: https://autogo.cc/#/index_/API/app Retrieves the activity name of the application currently running on the screen. This function does not require any input parameters. ```Go activityName := app.CurrentActivity() ``` -------------------------------- ### HUD Creation and Configuration Source: https://autogo.cc/#/index_/API/hud This section covers the creation of new HUD instances and the configuration of their appearance and behavior. ```APIDOC ## HUD Package Overview Provides heads-up display functionality, supporting multiple instances, colored text display, and more. ### TextItem Structure The `TextItem` struct defines the properties for displaying text within the HUD. **Fields** - **TextColor** (`color.Color`) - Required - The color of the text. Format: `"#FFFFFF" - **Text** (`string`) - Required - The text content to display. --- ## New Creates a new HUD instance. ### Method GET ### Endpoint /hud/new ### Description Initializes and returns a pointer to a new HUD instance. ### Response #### Success Response (200) - **HUD** (`*HUD`) - A pointer to the newly created HUD instance. ### Response Example ```json { "HUD": "" } ``` --- ## SetPosition Sets the position and size of the HUD. ### Method POST ### Endpoint /hud/{hud_instance_id}/position ### Parameters #### Query Parameters - **x1** (`int`) - Required - The x-coordinate of the top-left corner. - **y1** (`int`) - Required - The y-coordinate of the top-left corner. - **x2** (`int`) - Required - The x-coordinate of the bottom-right corner. - **y2** (`int`) - Required - The y-coordinate of the bottom-right corner. ### Description Configures the bounding box for the HUD on the screen. ### Response #### Success Response (200) - **HUD** (`*HUD`) - A pointer to the modified HUD instance. ### Response Example ```json { "HUD": "" } ``` --- ## SetBackgroundColor Sets the background color of the HUD. ### Method POST ### Endpoint /hud/{hud_instance_id}/background-color ### Parameters #### Query Parameters - **color** (`string`) - Required - The background color in hexadecimal format (e.g., `"#2D2D30"` or `"#2D2D3080"` for transparency). ### Description Applies a background color to the HUD, with support for transparency. ### Response #### Success Response (200) - **HUD** (`*HUD`) - A pointer to the modified HUD instance. ### Response Example ```json { "HUD": "" } ``` --- ## SetTextSize Sets the font size for the text displayed in the HUD. ### Method POST ### Endpoint /hud/{hud_instance_id}/text-size ### Parameters #### Query Parameters - **size** (`int`) - Required - The font size (recommended range: 30-60). ### Description Adjusts the visual size of the text elements within the HUD. ### Response #### Success Response (200) - **HUD** (`*HUD`) - A pointer to the modified HUD instance. ### Response Example ```json { "HUD": "" } ``` --- ## SetText Sets the text content to be displayed in the HUD, supporting multi-colored text. ### Method POST ### Endpoint /hud/{hud_instance_id}/text ### Parameters #### Request Body - **items** (`[]TextItem`) - Required - An array of `TextItem` objects, each specifying text color and content. ### Description Updates the text displayed in the HUD, allowing for different colors within the same text block. ### Request Example ```json { "items": [ { "TextColor": "#00FF00", "Text": "HP: " }, { "TextColor": "#FFFFFF", "Text": "100/100" } ] } ``` ### Response #### Success Response (200) - **HUD** (`*HUD`) - A pointer to the modified HUD instance. ### Response Example ```json { "HUD": "" } ``` --- ## Show Makes the HUD visible on the screen. ### Method POST ### Endpoint /hud/{hud_instance_id}/show ### Description Activates the display of the HUD. ### Response #### Success Response (200) - **HUD** (`*HUD`) - A pointer to the modified HUD instance. ### Response Example ```json { "HUD": "" } ``` --- ## Hide Hides the HUD from the screen. ### Method POST ### Endpoint /hud/{hud_instance_id}/hide ### Description Deactivates the display of the HUD. ### Response #### Success Response (200) - **HUD** (`*HUD`) - A pointer to the modified HUD instance. ### Response Example ```json { "HUD": "" } ``` --- ## IsVisible Checks if the HUD is currently visible. ### Method GET ### Endpoint /hud/{hud_instance_id}/is-visible ### Description Returns the visibility status of the HUD. ### Response #### Success Response (200) - **isVisible** (`bool`) - `true` if the HUD is visible, `false` otherwise. ### Response Example ```json { "isVisible": true } ``` --- ## Destroy Destroys the HUD instance and releases associated resources. ### Method DELETE ### Endpoint /hud/{hud_instance_id}/destroy ### Description Cleans up and removes the HUD instance. ### Response #### Success Response (200) - **message** (`string`) - Confirmation message indicating the HUD was destroyed. ### Response Example ```json { "message": "HUD instance destroyed successfully." } ``` --- ## Example Usage Demonstrates a complete workflow for creating, configuring, and updating a HUD. ### Code Example ```go package main import ( "time" "your_project/hud" "your_project/utils" ) func main() { // Create and configure HUD h := hud.New() h.SetPosition(50, 700, 450, 750) h.SetBackgroundColor("#3D000080") h.SetTextSize(45) for { // Set multi-colored text h.SetText([]hud.TextItem{ {TextColor: "#00FF00", Text: "Current Time: "}, {TextColor: "#FFFFFF", Text: time.Now().Format("2006-01-02 15:04:05")}, }) utils.Sleep(1000) } } ``` ``` -------------------------------- ### Send Broadcast with Intent Options Source: https://autogo.cc/#/index_/API/app Constructs an Intent using `IntentOptions` and sends it as a broadcast. This allows for inter-application communication. ```Go app.SendBroadcast(options) ``` -------------------------------- ### Get Description of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the description content of a UiObject. This method returns a string representing the accessibility description of the element. It does not have external dependencies. ```Go desc := uiObject.GetDesc() fmt.Println("控件描述内容:", desc) ``` -------------------------------- ### Go ImGui 基础示例 Source: https://autogo.cc/#/index_/API/imgui 演示了如何使用 Go 语言和 Dear ImGui 库创建图形用户界面。该示例展示了 ImGui 的初始化、主循环、窗口设置、文本显示、按钮交互以及按钮的样式化。它需要 `github.com/Dasongzi1366/AutoGo/imgui` 库。 ```go package main import ( "fmt" "github.com/Dasongzi1366/AutoGo/imgui" ) func main() { // 初始化 imgui.Init() // 状态变量 counter := 0 showWindow := true // 主循环 imgui.Run(func() { // 设置窗口 imgui.SetNextWindowSizeV(imgui.Vec2{X: 500, Y: 400}, imgui.CondOnce) imgui.SetNextWindowPosV(imgui.Vec2{X: 100, Y: 100}, imgui.CondOnce, imgui.Vec2{X: 0, Y: 0}) // 创建窗口 imgui.BeginV("示例窗口", &showWindow, 0) // 标题 imgui.Text("ImGui 示例程序") imgui.Separator() imgui.Spacing() // 计数器 imgui.Text(fmt.Sprintf("计数器: %d", counter)) // 按钮 if imgui.Button("增加") { counter++ } imgui.SameLine() if imgui.Button("减少") { counter-- } imgui.SameLine() if imgui.Button("重置") { counter = 0 } imgui.Spacing() imgui.Separator() imgui.Spacing() // 样式化按钮 imgui.Text("样式化按钮:") imgui.PushStyleColorVec4(imgui.ColButton, imgui.Vec4{X: 0.2, Y: 0.8, Z: 0.2, W: 1.0}) if imgui.Button("绿色按钮") { // 绿色按钮的操作 } imgui.PopStyleColor() imgui.SameLine() imgui.PushStyleColorVec4(imgui.ColButton, imgui.Vec4{X: 0.8, Y: 0.2, Z: 0.2, W: 1.0}) if imgui.Button("红色按钮") { // 红色按钮的操作 } imgui.PopStyleColor() // 结束窗口 imgui.End() }) // 阻塞主进程防止程序退出 select {} } ``` -------------------------------- ### Get Virtual Screen ID with vdisplay Source: https://autogo.cc/#/index_/API/vdisplay Retrieves the unique ID of the virtual screen. This ID can be used with tools like Scrcpy to view the screen. ```Go displayId := v.GetDisplayId() fmt.Printf("虚拟屏幕ID: %d\n", displayId) ``` -------------------------------- ### 设置剪贴板文本内容 (ime.SetClipText) Source: https://autogo.cc/#/index_/API/ime 设置剪贴板的文本内容。需要提供要设置的文本字符串作为参数。 ```Go ime.SetClipText("这是要复制到剪贴板的内容") ``` -------------------------------- ### Enable Application Source: https://autogo.cc/#/index_/API/app Enables a previously disabled application, allowing it to run and be launched again. This function requires the application's package name. ```Go app.Enable("com.tencent.mm") ``` -------------------------------- ### Get Text of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the text content of a UiObject. This method returns a string representing the visible text associated with the element. It does not have external dependencies. ```Go text := uiObject.GetText() fmt.Println("控件文本内容:", text) ``` -------------------------------- ### Create File or Directory (Go) Source: https://autogo.cc/#/index_/API/files Creates a file or a directory at the specified path. If the file or directory already exists, it returns true without performing any action. Accepts a string path. ```Go success := files.Create("/sdcard/new_file.txt")CopyErrorOK! ``` -------------------------------- ### Get ID of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the unique identifier (ID) of a UiObject. This method returns a string representing the element's ID. It does not have external dependencies. ```Go id := uiObject.GetId() fmt.Println("控件 ID:", id) ``` -------------------------------- ### Get Volume Levels Source: https://autogo.cc/#/index_/API/device Retrieves the current volume levels for media, notifications, and alarms. It also provides the maximum possible volume for each category. ```go volume := device.GetMusicVolume() notificationVolume := device.GetNotificationVolume() alarmVolume := device.GetAlarmVolume() maxMusicVolume := device.GetMusicMaxVolume() maxNotificationVolume := device.GetNotificationMaxVolume() maxAlarmVolume := device.GetAlarmMaxVolume() ``` -------------------------------- ### vdisplay - Show Preview Window Source: https://autogo.cc/#/index_/API/vdisplay 显示虚拟屏幕的预览窗口,该窗口可以在ImgUI界面中展示虚拟屏幕的实时画面并支持触摸操作。 ```APIDOC ## POST /vdisplay/{displayId}/preview_window/show ### Description Shows the preview window for the virtual display. This window displays the real-time screen content and supports touch input. ### Method POST ### Endpoint /vdisplay/{displayId}/preview_window/show ### Parameters #### Path Parameters - **displayId** (int) - Required - The ID of the virtual display. #### Query Parameters - **rotated** (bool) - Optional - If true, the preview window will be rotated by 90 degrees. Useful for displaying landscape content. ### Request Example ```json // No request body needed for this endpoint, parameters are in query string // Example: POST /vdisplay/123/preview_window/show?rotated=true ``` ### Response #### Success Response (200) - **status** (string) - Indicates the result of the operation (e.g., "success"). #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Resize - Go: Resize image Source: https://autogo.cc/#/index_/API/images 调整图像大小。需要提供要调整的图像以及目标宽度和高度。 ```Go resizedImg := images.Resize(img, 800, 600) ``` -------------------------------- ### Get Class Name of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the class name of a UiObject. This method returns a string representing the UI element's class. It does not have external dependencies. ```Go className := uiObject.GetClassName() fmt.Println("控件类名:", className) ``` -------------------------------- ### VolumeUp Source: https://autogo.cc/#/index_/API/motion Simulates pressing the Volume Up button. ```APIDOC ## VolumeUp ### Description Simulates pressing the Volume Up button. ### Method `motion.VolumeUp(displayId)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **displayId** (int) - Required - The screen ID (0 for the main screen, others for virtual screens). ### Request Example ```python motion.VolumeUp(0) ``` ### Response #### Success Response (200) Operation successful. #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### Get Index of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the index of a UiObject within its parent. This method returns an integer representing the position of the element among its siblings. It does not have external dependencies. ```Go index := uiObject.GetIndex() fmt.Println("控件在父控件中的索引:", index) ``` -------------------------------- ### Edit File with Application Source: https://autogo.cc/#/index_/API/app Opens a specified file for editing using another application. Similar to viewing, if the file doesn't exist, the editing application handles the situation. ```Go app.EditFile("/sdcard/example.txt") ``` -------------------------------- ### Create Virtual Screen with vdisplay Source: https://autogo.cc/#/index_/API/vdisplay Creates a virtual screen with specified width, height, and DPI. Returns a Vdisplay object on success or nil on failure. Requires Android 10+. ```Go v := vdisplay.Create(720, 1280, 320) if v != nil { fmt.Printf("创建成功,屏幕ID:%d\n", v.GetDisplayId()) } ``` -------------------------------- ### vdisplay - Set Preview Window Size Source: https://autogo.cc/#/index_/API/vdisplay 设置虚拟屏幕预览窗口的尺寸(宽度和高度)。 ```APIDOC ## PUT /vdisplay/{displayId}/preview_window/size ### Description Sets the size (width and height) of the virtual display preview window. ### Method PUT ### Endpoint /vdisplay/{displayId}/preview_window/size ### Parameters #### Path Parameters - **displayId** (int) - Required - The ID of the virtual display. #### Request Body - **width** (int) - Required - The desired width of the preview window in pixels. - **height** (int) - Required - The desired height of the preview window in pixels. ### Request Example ```json { "width": 800, "height": 600 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the result of the operation (e.g., "success"). #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get Drawing Order of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the drawing order of a UiObject within its parent. This method returns an integer indicating the Z-order or drawing sequence. It does not have external dependencies. ```Go drawingOrder := uiObject.GetDrawingOrder() fmt.Println("控件绘制次序:", drawingOrder) ``` -------------------------------- ### Home Source: https://autogo.cc/#/index_/API/motion Simulates pressing the Home button. ```APIDOC ## Home ### Description Simulates pressing the Home button. ### Method `motion.Home(displayId)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **displayId** (int) - Required - The screen ID (0 for the main screen, others for virtual screens). ### Request Example ```python motion.Home(0) ``` ### Response #### Success Response (200) Operation successful. #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### Set Console Window Size (Go) Source: https://autogo.cc/#/index_/API/console Sets the width and height of the console window. This function takes two integer arguments, width and height, to define the dimensions of the console. ```Go c.SetWindowSize(800, 600) ``` -------------------------------- ### Get Dismissable Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'dismissable' attribute of a UiObject. This method returns a boolean value indicating whether the UI element can be dismissed. It does not have external dependencies. ```Go dismissable := uiObject.GetDismissable() fmt.Println("控件是否可解散:", dismissable) ``` -------------------------------- ### Set Touch Callback for Virtual Screen Preview with vdisplay Source: https://autogo.cc/#/index_/API/vdisplay Sets a callback function to handle touch events within the virtual screen's preview window. Passing nil removes the current callback. ```Go v.SetTouchCallback(func(x, y, action, displayId int) { // 处理用户点击事件 }) ``` -------------------------------- ### Get Editable Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'editable' attribute of a UiObject. This method returns a boolean value indicating whether the UI element can be edited. It does not have external dependencies. ```Go editable := uiObject.GetEditable() fmt.Println("控件是否可编辑:", editable) ``` -------------------------------- ### Get Scrollable Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'scrollable' attribute of a UiObject. This method returns a boolean value indicating whether the UI element can be scrolled. It does not have external dependencies. ```Go scrollable := uiObject.GetScrollable() fmt.Println("控件是否可滚动:", scrollable) ``` -------------------------------- ### Launch Application in Virtual Screen with vdisplay Source: https://autogo.cc/#/index_/API/vdisplay Launches a specified application within the virtual screen. The application is identified by its package name. ```Go success := v.LaunchApp("com.example.app") if success { fmt.Println("应用启动成功") } ``` -------------------------------- ### Initialize YOLO Model Source: https://autogo.cc/#/index_/API/yolo Creates a YOLO instance with specified model version, CPU thread count, and paths to model parameters and binary files. It also takes a comma-separated string of labels. Returns an instance object on success or nil on failure. ```Go yolo := yolo.New("v8", 4, "/data/local/tmp/param", "/data/local/tmp/bin", "person,bicycle,car") if yolo == nil { fmt.Println("模型加载失败") return } fmt.Println("模型加载成功") ``` -------------------------------- ### Get Enabled Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'enabled' attribute of a UiObject. This method returns a boolean value indicating whether the UI element is enabled. It does not have external dependencies. ```Go enabled := uiObject.GetEnabled() fmt.Println("控件是否启用:", enabled) ``` -------------------------------- ### Get Checkable Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'checkable' attribute of a UiObject. This method returns a boolean value indicating whether the UI element can be checked. It does not have external dependencies. ```Go checkable := uiObject.GetCheckable() fmt.Println("控件是否可选中:", checkable) ``` -------------------------------- ### Get Clickable Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'clickable' attribute of a UiObject. This method returns a boolean value indicating whether the UI element can be clicked. It does not have external dependencies. ```Go clickable := uiObject.GetClickable() fmt.Println("控件是否可点击:", clickable) ``` -------------------------------- ### SetCallback - Go: Set image data arrival callback Source: https://autogo.cc/#/index_/API/images 设置一个新图像数据到达的回调函数。当新图像数据到达时,会调用此函数。如果传入 nil,则会移除当前设置的回调。回调函数应避免执行耗时操作,否则可能导致后续图像数据处理延迟。 ```Go images.SetCallback(func(img *image.NRGBA, displayId int) { // 处理新图像数据 }) ``` -------------------------------- ### Get Screen Brightness Mode Source: https://autogo.cc/#/index_/API/device Retrieves the current screen brightness adjustment mode. 0 indicates manual adjustment, and 1 indicates automatic adjustment. ```go mode := device.GetBrightnessMode() ``` -------------------------------- ### vdisplay - Launch Application Source: https://autogo.cc/#/index_/API/vdisplay 在指定的虚拟屏幕中启动一个应用程序,需要提供应用程序的包名。 ```APIDOC ## POST /vdisplay/{displayId}/launch_app ### Description Launches a specified application within the virtual display. ### Method POST ### Endpoint /vdisplay/{displayId}/launch_app ### Parameters #### Path Parameters - **displayId** (int) - Required - The ID of the virtual display. #### Request Body - **packageName** (string) - Required - The package name of the application to launch. ### Request Example ```json { "packageName": "com.example.app" } ``` ### Response #### Success Response (200) - **success** (bool) - True if the application was launched successfully, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Get File Name (Go) Source: https://autogo.cc/#/index_/API/files Extracts the file name from a given path. It takes the file path as a string and returns the file name including its extension. ```Go name := files.GetName("/sdcard/example.txt")CopyErrorOK! ``` -------------------------------- ### Recents Source: https://autogo.cc/#/index_/API/motion Displays the recent applications screen. ```APIDOC ## Recents ### Description Displays the recent applications screen. ### Method `motion.Recents(displayId)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **displayId** (int) - Required - The screen ID (0 for the main screen, others for virtual screens). ### Request Example ```python motion.Recents(0) ``` ### Response #### Success Response (200) Operation successful. #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### 模拟按下音量上键 (motion.VolumeUp) Source: https://autogo.cc/#/index_/API/motion 模拟按下设备的音量上键,用于增加音量。需要指定屏幕ID。 ```Python motion.VolumeUp(0) ``` -------------------------------- ### Get Child UiObject by Index Source: https://autogo.cc/#/index_/API/uiacc Retrieves a specific child UiObject by its index. This method takes an integer `index` as input and returns the corresponding child UiObject. It does not have external dependencies. ```Go child := uiObject.GetChild(0) fmt.Println("第一个子控件:", child) ``` -------------------------------- ### NewInstance Source: https://autogo.cc/#/index_/API/plugin Creates an instance of a specified class within an APK. Supports regular classes and static inner classes, with optional constructor arguments. ```APIDOC ## NewInstance ### Description Creates an instance of a specified class from an APK. This method supports both regular classes and static inner classes (using `$` as a separator). Optional constructor arguments can be provided. ### Method `NewInstance(className string, args ...interface{}) (*Instance, error)` ### Parameters #### Path Parameters - **className** (string) - Required - The fully qualified class name (e.g., "com.example.MyClass" or "com.example.MyClass$InnerClass"). - **args** (...interface{}) - Optional - Arguments for the constructor. ### Supported Argument Types - `int`, `int32` → Java `int` - `int64` → Java `long` - `float32` → Java `float` - `float64` → Java `double` - `bool` → Java `boolean` - `string` → Java `String` - `[]byte` → Java `byte[]` - `*image.NRGBA` → `android.graphics.Bitmap` (automatic conversion) - `plugin.Context` → `android.content.Context` (automatic retrieval) - `plugin.AssetManager` → `android.content.res.AssetManager` (automatic creation and APK path addition) ### Return Value - ***Instance** - An object instance of the specified class. Returns `nil` if creation fails. - **error** - An error object if instance creation fails, otherwise `nil`. ### Request Example ```go // Create an instance with a no-argument constructor instance, err := cl.NewInstance("com.example.MyClass") if err != nil { fmt.Println("Failed to create instance:", err) return } defer instance.Release() // Create an instance with arguments instance, err := cl.NewInstance("com.example.MyClass", "param1", int64(123), true) // Create an instance of a static inner class instance, err := cl.NewInstance("com.example.MyClass$InnerClass") ``` ``` -------------------------------- ### Get Package Name of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the package name of the application to which a UiObject belongs. This method returns a string representing the application's package name. It does not have external dependencies. ```Go packageName := uiObject.GetPackageName() fmt.Println("控件包名:", packageName) ``` -------------------------------- ### Get Bounds of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the screen coordinates (bounds) of a UiObject. This method returns a representation of the rectangle defining the element's position and size on the screen. It does not have external dependencies. ```Go bounds := uiObject.GetBounds() fmt.Printf("控件范围: %v\n", bounds) ``` -------------------------------- ### 模拟按下Home键 (motion.Home) Source: https://autogo.cc/#/index_/API/motion 模拟按下设备的Home键,用于返回主屏幕。需要指定屏幕ID。 ```Python motion.Home(0) ``` -------------------------------- ### Get Child Count of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the number of child UI elements for a given UiObject. This method returns an integer representing the count of direct children. It does not have external dependencies. ```Go childCount := uiObject.GetChildCount() fmt.Println("子控件数量:", childCount) ``` -------------------------------- ### 显示快速设置 (motion.QuickSettings) Source: https://autogo.cc/#/index_/API/motion 模拟下拉通知栏到底部,显示快速设置面板。此操作不接受任何参数。 ```Python motion.QuickSettings() ``` -------------------------------- ### Get Password Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'password' attribute of a UiObject. This method returns a boolean value indicating whether the UI element is a password field. It does not have external dependencies. ```Go password := uiObject.GetPassword() fmt.Println("控件是否为密码字段:", password) ``` -------------------------------- ### Reboot Device Source: https://autogo.cc/#/index_/API/device Reboots the device. ```go device.Reboot() ``` -------------------------------- ### Get Visible Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'visible' attribute of a UiObject. This method returns a boolean value indicating whether the UI element is currently visible. It does not have external dependencies. ```Go visible := uiObject.GetVisible() fmt.Println("控件是否可见:", visible) ``` -------------------------------- ### 获取剪贴板文本内容 (ime.GetClipText) Source: https://autogo.cc/#/index_/API/ime 获取当前系统的剪贴板中的文本内容。返回值为字符串类型。 ```Go text := ime.GetClipText() fmt.Println("剪贴板内容:", text) ``` -------------------------------- ### 调用返回 int 类型的方法 - Go Source: https://autogo.cc/#/index_/API/plugin 专门用于调用返回 `int` 类型结果的 Java 方法。它简化了类型转换,直接返回 Go 的 `int` 类型值,并包含错误处理。 ```go count, err := instance.CallInt("getCount") if err != nil { fmt.Println("调用失败:", err) } else { fmt.Printf("计数: %d\n", count) } ``` -------------------------------- ### Get Checked Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'checked' attribute of a UiObject. This method returns a boolean value indicating whether the UI element is currently checked. It does not have external dependencies. ```Go checked := uiObject.GetChecked() fmt.Println("控件是否被勾选:", checked) ``` -------------------------------- ### 传递 Context 参数给 Java 方法 - Go Source: https://autogo.cc/#/index_/API/plugin 展示了如何在 Go 代码中将 plugin.Context{} 作为参数传递给 Java 方法。这允许 Go 程序在调用 Java 方法时提供 Android 应用的上下文信息。 ```go // 传递Context参数给Java方法 instance.Call("methodNeedContext", plugin.Context{}, "otherParam") ``` -------------------------------- ### Get Selected Attribute of UiObject Source: https://autogo.cc/#/index_/API/uiacc Retrieves the 'selected' attribute of a UiObject. This method returns a boolean value indicating whether the UI element is currently selected. It does not have external dependencies. ```Go selected := uiObject.GetSelected() fmt.Println("控件是否被选中:", selected) ``` -------------------------------- ### Get All Data from Local Storage Table (Go) Source: https://autogo.cc/#/index_/API/storages Retrieves all key-value pairs from a specified table in local storage. This function is part of the storages package and returns a map of the data. ```Go data := storages.GetAll("data") for k, v := range data { fmt.Printf("%s = %s\n", k, v) } ``` -------------------------------- ### 获取输入法列表 (ime.GetIMEList) Source: https://autogo.cc/#/index_/API/ime 获取当前系统中所有可用的输入法列表。返回一个包含输入法信息的列表。 ```Go fmt.Println("输入法列表:",ime.GetIMEList()) ``` -------------------------------- ### Get Process Memory Usage - Go Source: https://autogo.cc/#/index_/API/system Retrieves the memory usage of a specified process. If the PID is 0, it fetches the memory usage of the current process. Requires the 'system' package. ```go memoryUsage := system.GetMemoryUsage(12345) fmt.Println("Memory Usage (KB):", memoryUsage) ``` -------------------------------- ### 弹出电源键菜单 (motion.PowerDialog) Source: https://autogo.cc/#/index_/API/motion 模拟按下电源键,弹出电源菜单。此操作不接受任何参数。 ```Python motion.PowerDialog() ``` -------------------------------- ### Get File Extension (Go) Source: https://autogo.cc/#/index_/API/files Obtains the extension of a file from its path. It takes the file path as a string and returns the file extension (e.g., ".txt"). ```Go extension := files.GetExtension("/sdcard/example.txt")CopyErrorOK! ``` -------------------------------- ### Print Text to Console (Go) Source: https://autogo.cc/#/index_/API/console Prints text to the console. This function supports multiple arguments and behaves similarly to fmt.Println, allowing for flexible output formatting. ```Go c.Println("Hello, world!") c.Println("用户ID:", 123, "状态:", "在线") ``` -------------------------------- ### 发送GET请求 Source: https://autogo.cc/#/index_/API/https 发送HTTP GET请求并返回响应状态码和数据。支持设置请求URL和超时时间。 ```Go code, data := https.Get("https://example.com", 5000) if code == 200 { fmt.Println("请求成功:", string(data)) } else { fmt.Println("请求失败,状态码:", code) } ``` -------------------------------- ### Set Selection for UiObject (Go) Source: https://autogo.cc/#/index_/API/uiacc Sets the selected text content for an input field UiObject. It takes start and end positions as integers. Returns a boolean indicating success. ```Go success := uiObject.SetSelection(0, 5) fmt.Println("设置选中内容是否成功:", success) ```