### Start QQ Chat Activity Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/intentType.html Launches the QQ chat window for a specific user. Requires the QQ package to be installed. ```javascript let qq = "2732014414"; app.startActivity({ action: "android.intent.action.VIEW", data: "mqq://im/chat?chat_type=wpa&version=1&src_type=web&uin=" + qq, packageName: "com.tencent.mobileqq", }); ``` -------------------------------- ### Start Service with Intent Options Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Constructs an Intent based on provided options and starts the corresponding Service. ```javascript app.startService(options); ``` -------------------------------- ### Floating Window Configuration Examples Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/console.html Provides examples of how to configure the floating console window using builder, chained, and traditional methods. ```APIDOC ## Floating Window Configuration Examples Here are examples of configuring a floating window with specific dimensions, position, title, and styles: * **Using the Builder Pattern:** ```javascript console.build({ size: [ 0.8, 0.6 ], position: [ 0.1, 0.15 ], title: 'HELLO WORLD', titleTextSize: 18, contentTextSize: 16, backgroundColor: 'deep-orange-900', titleBackgroundAlpha: 0.8, contentBackgroundAlpha: 0.5, exitOnClose: 6e3, }).show(); ``` * **Using Chained Method Calls:** ```javascript console .setSize(0.8, 0.6) .setPosition(0.1, 0.15) .setTitle('HELLO WORLD') .setTitleTextSize(18) .setContentTextSize(16) .setBackgroundColor('deep-orange-900') .setTitleBackgroundAlpha(0.8) .setContentBackgroundAlpha(0.5) .setExitOnClose(6e3) .show(); ``` * **Using Traditional Step-by-Step Configuration:** ```javascript console.setSize(0.8, 0.6); console.setPosition(0.1, 0.15); console.setTitle('HELLO WORLD'); console.setTitleTextSize(18); console.setContentTextSize(16); console.setBackgroundColor('deep-orange-900'); console.setTitleBackgroundAlpha(0.8); console.setContentBackgroundAlpha(0.5); console.setExitOnClose(6e3); console.show(); ``` ``` -------------------------------- ### Accept Header Examples Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/httpRequestHeadersType.html Provides examples of how to format the Accept header, including specific types, wildcards, and quality values for specifying preferences. ```http # 示例 accept: text/html accept: image/* accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8 ``` -------------------------------- ### Day.js Installation Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets/modules/dayjs/README.md Command to install Day.js using npm. ```bash npm install dayjs --save ``` -------------------------------- ### Start Activity with Intent Options Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Constructs an Intent based on provided options and starts the corresponding Activity. ```javascript app.startActivity({ action: "SEND", type: "text/plain", data: "file:///sdcard/1.txt" }); ``` -------------------------------- ### Input Dialog Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Create a dialog that prompts the user for input. This example shows how to set input hints and default values. ```javascript dialog({ title: "输入", inputHint: "请输入内容", inputPrefill: "默认内容", positive: "确定", negative: "取消" }).on("positive", (input) => { toast("输入内容: " + input); }).on("negative", () => { toast("取消输入"); }).show(); ``` -------------------------------- ### Install CMake Config File and Version Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs the main CMake configuration file (PNGConfig.cmake) and a version file (PNGConfigVersion.cmake) to support `find_package(PNG CONFIG)`. This is conditional on not skipping the config file installation. ```cmake if(NOT SKIP_INSTALL_CONFIG_FILE AND NOT SKIP_INSTALL_ALL) install(TARGETS ${PNG_LIBRARY_TARGETS} EXPORT PNGTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) include(CMakePackageConfigHelpers) write_basic_package_version_file(PNGConfigVersion.cmake VERSION ${PNGLIB_VERSION} COMPATIBILITY SameMinorVersion) install(EXPORT PNGTargets FILE PNGTargets.cmake NAMESPACE PNG:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/PNGConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG) endif() ``` -------------------------------- ### Get Installed Apps Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Retrieves a list of all installed application packages. The 'match' option can filter the list, and the 'get' option specifies which application details to include. ```javascript let apps = $app.getInstalledApps({ matcg }) ``` -------------------------------- ### Install Man Pages Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs the man pages for libpng. This includes man pages for the library and configuration utilities. ```cmake install(FILES libpng.3 libpngpf.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) install(FILES png.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5) ``` -------------------------------- ### List Dialog Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Demonstrates how to create a dialog with a list of selectable items. This example uses the 'select' mode for normal selection. ```javascript dialog({ title: "列表选择", items: ["选项1", "选项2", "选项3"], itemsSelectMode: "select", positive: "确定", negative: "取消" }).on("positive", (index) => { toast("选择了: " + index); }).show(); ``` -------------------------------- ### Install Pkg-config Files Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs the pkg-config files and associated configuration scripts. This is conditional and applies to non-native Windows builds. ```cmake if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() ``` -------------------------------- ### Install PNG Bin Targets Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs the PNG binary targets, typically executables, to the runtime destination directory. ```cmake install(TARGETS ${PNG_BIN_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Open URL in Browser Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Opens a given URL in the default web browser. If the URL does not start with 'http://' or 'https://', 'http://' is prepended. Throws ActivityNotException if no browser is installed. ```javascript app.openUrl(url); ``` -------------------------------- ### Install libpng Library Targets Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs the libpng library targets. This includes runtime, library, archive, and framework destinations. ```cmake install(TARGETS ${PNG_LIBRARY_TARGETS} EXPORT libpng RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) ``` -------------------------------- ### Accept-Language Header Examples Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/httpRequestHeadersType.html Shows examples of the Accept-Language header, demonstrating how to list preferred languages and their associated quality values for prioritization. ```http # 示例 accept-language: de accept-language: de-CH accept-language: en-US,en;q=0.5 accept-language: zh-CN, zh;q=0.8, zh-TW;q=0.7, zh-HK;q=0.5, en-US;q=0.3, en;q=0.2 ``` -------------------------------- ### Start Activity with Root Permissions Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Starts an activity using root permissions. Use `app.startActivity()` for this method. ```javascript app.startActivity({ packageName: "org.autojs.autojs", className: "org.autojs.autojs.ui.settings.SettingsActivity_", root: true }); ``` -------------------------------- ### Install Public Headers Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs the public header files for the libpng library. Headers are installed to the main include directory and a version-specific subdirectory. ```cmake install(FILES ${libpng_public_hdrs} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES ${libpng_public_hdrs} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}) ``` -------------------------------- ### Ensure App is Installed Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/appType.html Ensures that the application corresponding to the App enum instance is installed. Throws an exception if the app is not installed. ```javascript App.FIREFOX.ensureInstalled(); ``` -------------------------------- ### Install Configuration Executables Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs configuration executables like libpng-config. This is conditional and applies to non-native Windows builds. ```cmake if(NOT WIN32 OR CYGWIN OR MINGW) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION ${CMAKE_INSTALL_BINDIR}) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() ``` -------------------------------- ### Install Static Library Symlink and Files Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Creates a symlink for static libraries and installs the static library files. This is conditional on PNG_STATIC being true and not a native Windows build. ```cmake if(PNG_STATIC) if(NOT WIN32 OR CYGWIN OR MINGW) create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static) install(FILES $/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() endif() ``` -------------------------------- ### Progress Dialog Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Implement a progress dialog to show the user the status of an ongoing operation. This example shows a determinate progress bar. ```javascript var d = dialog({ title: "进度条", content: "正在进行中...", progress: { max: 100, horizontal: true, showMinMax: true } }); d.show(); var i = 0; var interval = setInterval(() => { i++; d.setProgress(i); if (i >= 100) { clearInterval(interval); d.dismiss(); } }, 50); ``` -------------------------------- ### ensureInstalled Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/appType.html Ensures that the application corresponding to the enum instance is installed on the device. Throws an exception if not installed. ```APIDOC ## ensureInstalled() ### Description Ensures that the application corresponding to the enum instance is installed on the device. Throws an exception if not installed. ### Returns - `void` ### Example ```javascript App.FIREFOX.ensureInstalled(); ``` ``` -------------------------------- ### Start a New Thread with threads.start Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Launches a new thread to execute a given function. The main thread waits for all started threads to complete unless explicitly managed. ```javascript threads.start(function(){ //在新线程执行的代码 while(true){ log("子线程"); } }); while(true){ log("脚本主线程"); } ``` -------------------------------- ### Example: Auto Clicker using press() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/automator.html An example demonstrating how to create a simple auto-clicker using the `press()` function to repeatedly click at a specific location. ```javascript //循环100次 for(var i = 0; i < 100; i++){ //点击位置(500, 1000), 每次用时1毫秒 press(500, 1000, 1); } ``` -------------------------------- ### Install Shared Library Symlink and Files Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Creates a symlink for shared libraries (e.g., libpng.dll.a to libpng16.dll.a on Cygwin) and installs the shared library files. This is conditional on PNG_SHARED being true and not a native Windows build. ```cmake if(PNG_SHARED) # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin if(NOT WIN32 OR CYGWIN OR MINGW) create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared) install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() endif() ``` -------------------------------- ### Example: Pinch Gesture using gestures() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/automator.html An example demonstrating how to simulate a pinch gesture using the `gestures()` function, involving two points moving towards a common center. ```javascript gestures([0, 500, [800, 300], [500, 1000]], [0, 500, [300, 1500], [500, 1000]]); ``` -------------------------------- ### app.getAppName Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Gets the name of an installed application by its package name. ```APIDOC ## app.getAppName(packageName) ### Description Gets the name of an installed application by its package name. Returns null if the application is not found. This function can also be used as a global function. ### Parameters #### Path Parameters - **packageName** (string) - The package name of the application. ### Returns - (string | null) The name of the application, or null if not found. ### Example ```javascript var name = getAppName("com.tencent.mobileqq"); // Returns "QQ" ``` ``` -------------------------------- ### String.prototype.padStart() and String.prototype.padEnd() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/doc/RHINO.md Shows how to pad the current string with another string (repeated, if needed) so that the resulting string reaches a given length, either from the start or the end. ```APIDOC ## String.prototype.padStart() and String.prototype.padEnd() ### Description `padStart()` pads the current string with another string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the start of the current string. `padEnd()` pads the current string with another string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end of the current string. ### padStart(targetLength, padString) - **targetLength** (Number) - The length of the resulting string once the current string has been padded. If this value is less than or equal to the length of the current string, the current string is returned unchanged. - **padString** (String, optional) - The string to pad the current string with. Defaults to ' ' (U+0020). - **Returns**: (String) The padded string. ### padEnd(targetLength, padString) - **targetLength** (Number) - The length of the resulting string once the current string has been padded. If this value is less than or equal to the length of the current string, the current string is returned unchanged. - **padString** (String, optional) - The string to pad the current string with. Defaults to ' ' (U+0020). - **Returns**: (String) The padded string. ### Example ```javascript let h = '9'; let m = '30'; let s = '7'; let pad = o => o.padStart(2, '0'); `${pad(h)}:${pad(m)}:${pad(s)}`; // '09:30:07' pad = o => o.padEnd(2, '_'); `${pad(h)}:${pad(m)}:${pad(s)}`; // '9_:30:7_' ``` ``` -------------------------------- ### app.getPackageName Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Gets the package name of an installed application by its name. ```APIDOC ## app.getPackageName(appName) ### Description Gets the package name of an installed application by its name. Returns null if the application is not found. If the name corresponds to multiple applications, the package name of one of them will be returned. This function can also be used as a global function. ### Parameters #### Path Parameters - **appName** (string) - The name of the application. ### Returns - (string | null) The package name of the application, or null if not found. ### Example ```javascript var name = getPackageName("QQ"); // Returns "com.tencent.mobileqq" ``` ``` -------------------------------- ### Get App Name (Firefox) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/appType.html Retrieves the application name for an installed app. If the app is not installed, it fetches the pre-defined name from the App enum instance. ```javascript console.log(App.FIREFOX.getAppName()); ``` -------------------------------- ### ApkSigner Usage Examples Source: https://github.com/supermonster003/autojs6/blob/master/modules/apk-signer/src/main/java/com/android/apksigner/help.txt Demonstrates basic usage of the apksigner tool for signing and verifying APK files. ```bash apksigner sign --ks release.jks app.apk ``` ```bash apksigner verify --verbose app.apk ``` -------------------------------- ### auto.rootInActiveWindow Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Gets the root element of the currently active window. Returns null if the accessibility service is not started. ```APIDOC ## auto.rootInActiveWindow() ### Description Gets the root element of the currently active window (the window with focus or being touched). Returns null if the accessibility service is not started. ### Returns * {UiObject | null} - The root element of the active window or null. ``` -------------------------------- ### packageNameStartsWith(str) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiSelectorType.html Selects UI elements belonging to applications whose package name starts with the specified string. ```APIDOC ## packageNameStartsWith(str) ### Description Selects UI elements belonging to applications whose package name begins with the specified string. ### Parameters #### Path Parameters - **str** (string) - Required - The string that the package name must start with. ``` -------------------------------- ### Get Current API Level Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/apiLevel.html Logs the current device's API level to the console. For example, it might output '30'. ```javascript console.log(device.sdkInt); /* e.g. 30 */ ``` -------------------------------- ### auto.root Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Gets the root element of the current window's layout. Returns null if the accessibility service is not started or if the WindowFilter returns false. ```APIDOC ## auto.root() ### Description Gets the root element of the current window's layout. Returns null if the accessibility service is not started or if the WindowFilter returns false. If no windowFilter is set, the current window is the active window (the window with focus or being touched). If a windowFilter is set, it retrieves the first window from the filtered windows. On systems below Android 5.0, it always returns the root element of the currently active window. ### Returns * {UiObject | null} - The root element of the window's layout or null. ``` -------------------------------- ### app.startService(options) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Constructs an Intent based on the provided options and starts the corresponding service. Services can perform long-running operations in the background. ```APIDOC ## app.startService(options) ### Description Constructs an Intent based on the provided options and starts the corresponding service. ### Parameters #### Options Object - `action` (string) - The action to perform. - `type` (string) - The MIME type of the data. - `data` (string) - The URI of the data. - `packageName` (string) - The package name of the target application. - `className` (string) - The class name of the target Service. - `flags` (Array) - Flags to modify the behavior of the Intent. - `root` (boolean) - Whether to start the service with root privileges. ### Request Example ```javascript app.startService({ packageName: "com.example.myservice", className: "com.example.myservice.MyService", action: "com.example.START_SERVICE" }); ``` ``` -------------------------------- ### getAppName Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/appType.html Retrieves the application name. It first tries to get the name of the installed app, and if not found, it uses the pre-defined name from the App enum instance. ```APIDOC ## getAppName() ### Description Retrieves the application name. It first tries to get the name of the installed app, and if not found, it uses the pre-defined name from the App enum instance. ### Returns - `string`: The application name. ### Example ```javascript // "Firefox" console.log(App.FIREFOX.getAppName()); ``` ``` -------------------------------- ### Array Iterator Examples (keys, values, entries) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/doc/RHINO.md Demonstrates using Array iterators to get keys, values, or key-value pairs from an array, including sparse arrays. ```javascript let a = [1,,,4]; a.length; // 4 Object.keys(a); // ['0', '3'] Array.from(a.keys()); // [0, 1, 2, 3] Object.values(a); // [1, 4] Array.from(a.values()); // [1, undefined, undefined, 4] Object.entries(a); // [['0', 1], ['3', 4]] Array.from(a.entries()); // [[0, 1], [1, undefined], [2, undefined], [3, 4]] ``` -------------------------------- ### OK() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/keys.html Simulates a press of the physical OK button using root privileges. ```APIDOC ## OK() ### Description Simulates a press of the physical OK button. This function relies on root privileges. ### Method `OK()` ``` -------------------------------- ### UiObject Instantiation and Usage Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiObjectType.html Demonstrates how to obtain a UiObject using the 'pickup' function and how to check its type. It also shows an example of chained method calls for navigating the UI hierarchy. ```APIDOC ## Obtaining and Using UiObject UiObjects are typically obtained using selectors. The `pickup` function can be used to find a UiObject based on a regular expression. ### Method `pickup(regex)` ### Parameters #### Path Parameters - `regex` (RegExp) - A regular expression to match against UI element properties. ### Request Example ```javascript // Get a UiObject with any text let w = pickup(/.+/); // Check if the object is null (when no matching element is found) console.log(w === null); // Check if 'w' is an instance of UiObject console.log(w instanceof UiObject); ``` ### Chained Method Calls Many UiObject instance methods return `this`, enabling chained calls. ### Request Example ```javascript let w = pickup('hello'); // Get the 2nd index child of the 3rd parent of control 'w' w.parent().parent().parent().child(2); ``` ``` -------------------------------- ### app.openUrl(url) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Opens a given URL in the default web browser. If the URL does not start with 'http://' or 'https://', 'http://' will be prepended. Throws an ActivityNotException if no browser app is installed. ```APIDOC ## app.openUrl(url) ### Description Opens a specified URL using the device's default web browser. If the provided URL lacks a scheme (e.g., 'http://' or 'https://'), it defaults to 'http://'. This function will throw an `ActivityNotException` if no web browser application is available on the device. ### Parameters #### Path Parameters - **url** (string) - Required - The URL to open. Defaults to 'http://' if no scheme is present. ### Request Example ```javascript // Open Google's homepage app.openUrl("https://www.google.com"); ``` ``` -------------------------------- ### app.startActivity(options) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/app.html Constructs an Intent based on the provided options and starts the corresponding Activity. This method is used to launch new activities within the application or other applications. ```APIDOC ## app.startActivity(options) ### Description Constructs an Intent based on the provided options and starts the corresponding Activity. ### Parameters #### Options Object - `action` (string) - The action to perform (e.g., "VIEW", "SEND"). - `type` (string) - The MIME type of the data (e.g., "image/png", "text/plain"). - `data` (string) - The URI of the data to be acted upon (e.g., "file:///sdcard/1.png"). - `packageName` (string) - The package name of the target application. - `className` (string) - The class name of the target Activity. - `flags` (Array) - Flags to modify the behavior of the Intent (e.g., `["activity_new_task", "grant_read_uri_permission"]`). - `root` (boolean) - Whether to start the activity with root privileges. If true, use `app.startActivity({...})` instead of `context.startActivity()`. ### Request Example ```javascript app.startActivity({ action: "SEND", type: "text/plain", data: "file:///sdcard/1.txt" }); ``` ```javascript app.startActivity({ packageName: "org.autojs.autojs", className: "org.autojs.autojs.ui.settings.SettingsActivity_", root: true }); ``` ``` -------------------------------- ### Capture Stack Trace Hiding Specific Frames Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/exceptions.html Use the 'constructorOpt' parameter to hide frames from the stack trace starting from a specified function. This example hides frames from function 'b' upwards. ```javascript let info = {}; try { function a() { /* b (含) 及其栈顶方向的所有函数调用均将隐藏. */ Error.captureStackTrace(info, b); return (0.5).toFixed(-1); } function b() { a(); } !function c() { b(); }(); } catch (e) { /* stack 信息中 b 和 a 被隐藏, 仅 c 被保留. */ console.log(info.stack); } ``` -------------------------------- ### Loading Plugins Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/plugins.html Demonstrates how to load application and project plugins using the `load` function. ```APIDOC ## load(appPluginPackageName) ### Description Loads an application plugin using its package name. ### Method `load` ### Parameters #### Path Parameters - **appPluginPackageName** (string) - Required - The package name of the application plugin to load. ## load(projectPluginName) ### Description Loads a project plugin using its name. ### Method `load` ### Parameters #### Path Parameters - **projectPluginName** (string) - Required - The name of the project plugin to load. ``` -------------------------------- ### AES Encryption Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Demonstrates AES encryption with default and custom output formats. The default transformation is ECB with PKCS5Padding. ```javascript let message = 'hello'; /* 创建密钥实例. */ /* 密钥长度需为 [ 16, 24, 32 ] 之一. */ let key = new crypto.Key('a'.repeat(16)); /* 加密数据, 输出格式保持默认, 即 bytes. */ console.log(crypto.encrypt(message, key, 'AES')); // [-20, 97, -47, 124, 88, 10, 85, -42, -128, -117, 11, 98, -33, -85, 106, 13] /* 输出格式修改为 Base64. */ console.log(crypto.encrypt(message, key, 'AES', { output: 'base64' })); // 7GHRfFgKVdaAiwti36tqDQ== /* AES 默认工作模式为 ECB, 默认填充方式为 PKCS5Padding, 结果同上. */ console.log(crypto.encrypt(message, key, 'AES/ECB/PKCS5Padding', { output: 'base64' })); // 7GHRfFgKVdaAiwti36tqDQ== ``` -------------------------------- ### String Type Matching Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiSelectorType.html When the filter condition is a string type, it's treated as a pattern for a regular expression, with implicit start ('^') and end ('$') anchors. For example, the string 'abc' is processed as the regex /^abc$/. ```APIDOC ## String Type Matching When the filter condition is a string type, it's equivalent to the `pattern` argument of JavaScript's `RegExp.prototype.constructor`, but with implicit start ('^') and end ('$') anchors for exact matching. For example, the string `'abc'` is processed as the regular expression `/^abc$/`. The string `'\d+'` is processed as the regular expression `/^\\d+$/`. ### Examples: ```javascript // Equivalent to descMatch(/^s.*did$/) descMatches('s.*did'); // Equivalent to descMatch(/^did$/) descMatches('did'); // Equivalent to descMatch(/^.*did.*$/) descMatches('.*did.*'); // Equivalent to descMatch(/^$/) descMatches(''); ``` **Note:** The `xxxMatches` methods are deprecated and `xxxMatch` should be used instead for consistency with JavaScript's `match` behavior. ``` -------------------------------- ### Prefix Matching Selector (startsWith) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiSelectorType.html Filters UI elements where a specific attribute's string value starts with the provided prefix. Example uses `descStartsWith` to match elements based on their description attribute. ```javascript descStartsWith('spl'); ``` -------------------------------- ### Home() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/keys.html Simulates a press of the Home button using root privileges. ```APIDOC ## Home() ### Description Simulates a press of the Home button. This function relies on root privileges. ### Method `Home()` ``` -------------------------------- ### Create and Use Local Storage Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/storages.html Creates a local storage instance with a given name and demonstrates putting and getting key-value pairs. If a storage with the same name already exists, a copy is returned, not a reference. ```javascript /* 创建一个名为 fruit 的本地存储. */ let sto = storages.create('fruit'); /* 存入 "键值对" 数据. */ sto.put('apple', 10); sto.put('banana', 20); /* 访问数据. */ sto.get('apple'); // 10 sto.get('banana'); // 20 sto.get('cherry'); // undefined ``` ```javascript let stoFruit = storages.create('fruit'); let stoPhone = storages.create('phone'); /* "键" 名均为 apple, 不同的本地存储之间数据独立. */ stoFruit.put('apple', 7); stoPhone.put('apple', 3); /* 访问数据 */ stoFruit.get('apple') // 7 stoPhone.get('apple') // 3 ``` ```javascript let sto = storages.create('fruit'); sto.put('apple', 10); /* 名为 fruit 的本地存储已创建, 因此返回的是存储副本. */ let stoCopied = storages.create('fruit'); /* 虽然 stoCopied 没有存入 apple 数据, 但 fruit 本地存储中存在. */ stoCopied.get('apple'); // 10 /* 副本与原始的本地存储并非引用关系. */ sto === stoCopied; // false ``` -------------------------------- ### Install Export File for CMake Users Source: https://github.com/supermonster003/autojs6/blob/master/libs/imagequant/external/libpng/CMakeLists.txt Installs an export file that CMake users can include to import libpng targets. This is conditional on not skipping export installation. ```cmake if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) install(EXPORT libpng DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpng FILE libpng${PNGLIB_ABI_VERSION}.cmake) endif() ``` -------------------------------- ### Variable Parameters Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/documentation.html Illustrates how to use variable parameters with the 'files.join' method. Variable parameters allow passing zero or more arguments. ```javascript let p = files.getSdcardPath(); files.join(p); /* 0 个可变参数 */ files.join(p, 'a'); /* 1 个可变参数 */ files.join(p, 'a', 'b', 'c', 'd'); /* 4 个可变参数 */ ``` -------------------------------- ### Array.from() and Array.of() Examples Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/doc/RHINO.md Demonstrates creating arrays from iterables or array-like objects, and creating arrays with specific arguments. ```javascript Array.from('123'); // ['1', '2', '3'] Array.from('123', Number); // [1, 2, 3] Array.of('hello', 'world'); // ['hello', 'world'] ``` -------------------------------- ### openSettings Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/appType.html Navigates to the application details page for the application corresponding to the enum instance. Returns false if the app is not installed or an error occurs during navigation. ```APIDOC ## openSettings() ### Description Navigates to the application details page for the application corresponding to the enum instance. Returns false if the app is not installed or an error occurs during navigation. ### Returns - `boolean`: `true` if navigation was successful, `false` otherwise. ### Example ```javascript /* e.g. true */ console.log(App.FIREFOX.openSettings()); ``` ``` -------------------------------- ### randInt(start, stop) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/mathx.html Generates a random integer within a specified range (inclusive). The start and stop parameters can be automatically swapped if provided in the wrong order. If start and stop are equal, that value is returned. ```APIDOC ## randInt(start, stop) ### Description Generates a random integer within a specified range (inclusive). ### Parameters * **start** (number) - The inclusive start of the range. * **stop** (number) - The inclusive end of the range. ### Returns * (number) - A random integer within the specified range. ### Example ```javascript // Generate a random integer between 10 and 20 (inclusive). console.log(Mathx.randInt(10, 20)); // e.g. 13 // Start and stop can be swapped. console.log(Mathx.randInt(20, 10)); // Same as randInt(10, 20) // If start and stop are equal, that value is returned. console.log(Mathx.randInt(15, 15)); // 15 ``` ``` -------------------------------- ### Check if App is Installed Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/appType.html Checks if the application corresponding to the App enum instance is installed on the device. ```javascript console.log(App.ALIPAY.isInstalled()); ``` -------------------------------- ### Pickup Selector Examples Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiSelectorType.html Demonstrates how to use various UiSelector methods within a pickup selector. ```javascript pickup(descMatches(/.*t\w{0,3}/), '@'); ``` ```javascript pickup({ descMatches: /.*t\w{0,3}/ }, '@'); ``` ```javascript pickup({ descMatches: [ /.*t\w{0,3}/ ] }, '@'); ``` ```javascript pickup(descMatch(/t\w{0,3}/), '@'); ``` ```javascript pickup({ descMatch: /t\w{0,3}/ }, '@'); ``` ```javascript pickup({ descMatch: [ /t\w{0,3}/ ] }, '@'); ``` ```javascript pickup(content('start'), '@'); ``` ```javascript pickup({ content: 'start' }, '@'); ``` ```javascript pickup({ content: [ 'start' ] }, '@'); ``` ```javascript pickup(contentStartsWith('star'), '@'); ``` ```javascript pickup({ contentStartsWith: 'star' }, '@'); ``` ```javascript pickup({ contentStartsWith: [ 'star' ] }, '@'); ``` -------------------------------- ### dragStart() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiObjectCollectionType.html Initiates a drag operation starting from each UI object in the collection. ```APIDOC ## dragStart() ### Description Initiates a drag operation from each UI object within this collection. ### Method `dragStart()` ### Parameters None ### Response None ``` -------------------------------- ### Chain SetSize and Show for Console Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Demonstrates chaining the setSize() and show() methods for the console, allowing for concise configuration and display of the floating window. ```javascript console.setSize(500, 800).show(); ``` -------------------------------- ### Chain Show and SetSize for Console Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Demonstrates chaining the show() and setSize() methods for the console, allowing for concise configuration and display of the floating window. ```javascript console.show().setSize(500, 800); ``` -------------------------------- ### Generate Random Integer within Range Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/mathx.html Returns a random integer within the specified start and stop range (inclusive). The start and stop values can be automatically swapped if out of order. If start and stop are equal, the function returns that value. ```javascript console.log(Mathx.randInt(10, 20)); // e.g. 13 ``` ```javascript console.log(Mathx.randInt(20, 10)); /* 与 randInt(10, 20) 效果相同. */ ``` ```javascript console.log(Mathx.randInt(15, 15)); // 15 ``` -------------------------------- ### Create Version Instance from String Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/versionType.html Use the Version constructor with a string to create a Version instance. The string must start with a digit and follow the format %major%.%minor%.%patch%.%suffix%. ```javascript let verA = new Version('3.0.2'); let verB = new Version('5.2.3'); ``` ```javascript let verA = new Version('5'); /* 相当于 '5.0.0' . */ let verB = new Version('5.2'); /* 相当于 '5.2.0' . */ let verC = new Version('5.2.3'); let verD = new Version('5.2.3-alpha11'); /* alpha11 为后缀. */ ``` -------------------------------- ### Global Action Examples Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiObjectActionsType.html Demonstrates direct calls to global actions, which are equivalent to using UiSelector methods. ```javascript copy(); /* 相当于 selector().copy(). */ paste(); /* 相当于 selector().paste(). */ clearFocus(); /* 相当于 selector().clearFocus(). */ imeEnter(); /* 相当于 selector().imeEnter(). */ ``` ```javascript click(1, 2); /* 相当于 automator.click(1, 2). */ longClick(1, 2); /* 相当于 automator.longClick(1, 2). */ setText("hello"); /* 相当于 automator.setText("hello"). */ scrollUp(); /* 相当于 automator.scrollUp(). */ scrollDown(); /* 相当于 automator.scrollDown(). */ ``` -------------------------------- ### build Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/console.html Builds the console with specified options. ```APIDOC ## build(options) ### Description Builds the console window with the provided configuration options. ### Method console.build ### Parameters #### Path Parameters - **options** (object) - Required - Configuration options for building the console. ``` -------------------------------- ### Pad String Start and End in JavaScript Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/doc/RHINO.md String.prototype.padStart() and padEnd() add padding to the start or end of a string until it reaches a target length. ```javascript let h = '9'; let m = '30'; let s = '7'; let pad = o => o.padStart(2, '0'); `${pad(h)}:${pad(m)}:${pad(s)}`; // '09:30:07' pad = o => o.padEnd(2, '_'); `${pad(h)}:${pad(m)}:${pad(s)}`; // '9_:30:7_' ``` -------------------------------- ### quickSettings() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/keys.html Shows the quick settings panel. This function relies on the accessibility service. ```APIDOC ## quickSettings() ### Description Shows the quick settings panel (pulls down the notification bar completely). Returns whether the operation was successful. This function relies on the accessibility service. ### Method `quickSettings()` ### Returns - `boolean`: True if the operation was successful, false otherwise. ``` -------------------------------- ### ApkSigner Commands Overview Source: https://github.com/supermonster003/autojs6/blob/master/modules/apk-signer/src/main/java/com/android/apksigner/help.txt Lists the available commands for the apksigner tool and their basic functions. ```bash apksigner rotate Add a new signing certificate to the SigningCertificateLineage ``` ```bash apksigner sign Sign the provided APK ``` ```bash apksigner verify Check whether the provided APK is expected to verify on Android ``` ```bash apksigner lineage Modify the capabilities of one or more signers in an existing SigningCertificateLineage ``` ```bash apksigner version Show this tool's version number and exit ``` ```bash apksigner help Show this usage page and exit ``` -------------------------------- ### Color Constructors Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/colorType.html Demonstrates the different ways to instantiate a Color object. ```APIDOC ## Color Constructors ### Description Provides methods to create Color objects. ### Constructors #### `Color(color: Color)` Creates a new Color object by copying an existing Color object. #### `Color(red: number, green: number, blue: number, alpha?: number)` Creates a new Color object using RGBA values. Alpha is optional and defaults to 255 if not provided. #### `Color(themeColor: string)` Creates a new Color object from a theme color string. (Note: Specific theme color strings are not detailed here.) ``` -------------------------------- ### Array.prototype.fill() and copyWithin() Examples Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/doc/RHINO.md Shows how to fill arrays with a static value and how to copy a sequence of elements within an array. ```javascript let a = Array(4).fill('x'); // ['x', 'x', 'x', 'x'] a.fill('y', 3); // ['x', 'x', 'x', 'y'] a.fill('z', 0, 2); // ['z', 'z', 'x', 'y'] [1, 2, 3, 4, 5].copyWithin(-2, -3, -1); // [1, 2, 3, 3, 4] [].copyWithin.call(new Int32Array([1, 2, 3]), 0, 2, 3); // [3, 2, 3] ``` -------------------------------- ### ES6 Class Inheritance Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/util.html An example showcasing modern ES6 class inheritance using the `extends` keyword, which is the recommended approach over `util.inherits()`. ```javascript const EventEmitter = require('events'); class MyStream extends EventEmitter { write(data) { this.emit('data', data); } } const stream = new MyStream(); stream.on('data', (data) => { console.log(`Received data: "${data}"`); }); stream.write('With ES6'); ``` -------------------------------- ### classNameStartsWith(str) Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiSelectorType.html Selects UI elements whose class name starts with the specified string. ```APIDOC ## classNameStartsWith(str) ### Description Selects UI elements whose class name begins with the specified string. ### Parameters #### Path Parameters - **str** (string) - Required - The string that the element's class name must start with. ``` -------------------------------- ### Basic HTTP GET Request Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/http.html Performs a simple GET request to a URL and checks the status code. Use this for basic data retrieval. ```javascript let response = http.get('www.github.com'); if (response.statusCode === 200) { console.log('请求成功'); } else { console.log('请求失败'); } ``` -------------------------------- ### Day.js Basic Usage Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets/modules/dayjs/README.md Demonstrates chaining Day.js methods for date manipulation and formatting. ```javascript dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss'); ``` -------------------------------- ### images.findMultiColors Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Performs multi-point color searching within an image. It first finds a starting color and then checks for a pattern of other colors relative to the starting point. ```APIDOC ## images.findMultiColors(img, firstColor, colors, options) ### Description Performs multi-point color searching within an image. It first finds a starting color and then checks for a pattern of other colors relative to the starting point. ### Method images.findMultiColors ### Parameters #### Path Parameters - **img** (Image) - The image to search within. - **firstColor** (number | string) - The first color to find. - **colors** (Array) - An array of [x, y, color] representing the relative positions and colors of other points to find. - **options** (Object) - Optional. Configuration options. - **region** (Array) - Optional. The search region, specified as [x, y, width, height] or [x, y]. Defaults to the entire image. - **threshold** (number) - Optional. The color similarity threshold, ranging from 0 to 255. Defaults to 4. ### Returns - **Point** - The coordinates of the first found color, or null if the pattern is not found. ### Example ```javascript var p = images.findMultiColors(img, "#123456", [[10, 20, "#ffffff"], [30, 40, "#000000"]], { region: [0, 960, 1080, 960] }); ``` ``` -------------------------------- ### OCR Paddle RecognizeText Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Example of using the OCR Paddle engine to recognize text. This is one of the six code forms available for Paddle. ```javascript ocr.paddle.recognizeText(...) ``` -------------------------------- ### Power() Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/keys.html Simulates a press of the Power button using root privileges. ```APIDOC ## Power() ### Description Simulates a press of the Power button. This function relies on root privileges. ### Method `Power()` ``` -------------------------------- ### dragStart Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/uiObjectActionsType.html Initiates a drag operation starting from the current UI object. ```APIDOC ## dragStart() ### Description Initiates a drag operation starting from the current UI object. ### Method N/A (Method call) ### Endpoint N/A ### Parameters None ### Request Example ``` dragStart() ``` ### Response None ``` -------------------------------- ### OCR Paddle Detect Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Example of using the OCR Paddle engine to detect text. This is one of the six code forms available for Paddle. ```javascript ocr.paddle.detect(...) ``` -------------------------------- ### OCR MLKit RecognizeText Example Source: https://github.com/supermonster003/autojs6/blob/master/app/src/main/assets-app/docs/all.html Example of using the OCR MLKit engine to recognize text. This is one of the six code forms available for MLKit. ```javascript ocr.mlkit.recognizeText(...) ```