# Android Macro Docs - Full Markdown Export Base site: https://androidmacro.com ## Basic Canonical URL: https://androidmacro.com/docs/basic Markdown URL: https://androidmacro.com/docs/basic.md # Basic Canonical URL: https://androidmacro.com/docs/basic Source file: /docs/basic/_category_.json --- Learn the most important android macro concepts. ## Pages - [Detect Image/Text](https://androidmacro.com/docs/basic/detect-image-or-text.md) - [How To Use](https://androidmacro.com/docs/basic/how-to-use.md) - [Perform Touch Interaction](https://androidmacro.com/docs/basic/perform-ui-interaction.md) - [Wait Until Image or Text Appears or Vanishes](https://androidmacro.com/docs/basic/wait-image-or-text.md) ## Detect Image/Text Canonical URL: https://androidmacro.com/docs/basic/detect-image-or-text Markdown URL: https://androidmacro.com/docs/basic/detect-image-or-text.md # Detect Image/Text Canonical URL: https://androidmacro.com/docs/basic/detect-image-or-text Source file: /docs/basic/detect-image-or-text.md --- It's essential to use image detection and text detection in certain games or tasks where the location of coordinates on the screen is always changing. For image detection, we use a so-called template, which is a part of an image that needs to be found on your screen. As for text detection, any text that appears on your screen can be detected. ## Image detection Before you can use image detection you need to capture a template in your device screen, to capture the template you can follow this steps: #### 1. Click Capture Template ![Home Page](/img/capture-screenshot.png) #### 2. Take Screenshot Area To Use For Detection ![Home Page](/img/capture-template-1.png) #### 3. Save Your Image Template ![Home Page](/img/capture-template-3.png) Once we saved the template image, we can use the template to perform image detection. For image detection you can use `Screen:click()`. For example #### Equivalent Code ```js # click 'stop-button.jpg' Screen:click('stop-button.jpg'); ``` #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. ## Text detection For text detection you can use `Screen:click()` method but you need to pass `ClickParams():setDetectionType('TEXT')` on second arguments to modify the click behaviour. The `setDetectionType` accept only 2 value `TEXT` and `IMAGE` by default the detection type is `IMAGE`. So in order for you to perform text recognition is to change `setDetectionType` value to `TEXT`. For example #### Equivalent Code ```js Screen:click('your text', ClickParams():setDetectionType('TEXT'):setDetectionMethod(1)) ``` #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. If you take a closer look, there are 2 type of text detection methods: 1. Word By Word (Default) If you use this method, the text detection will break match into several word pieces, in this case the best scenario is when you want to detect 1 word only 2. Line By Line If you use this method, the text detection will break match into several line pieces, in this case the best case scenario is when you want to detect 2 or more words at the same times To change the detection method you can use modify the value of `setDetectionMethod()`. The parameter of this function are: - `1` for Word by Word - `2` for Line by Line ## Next Step Once you are comfortable with basic detection, read [Detection Strategies](../setting/detection-strategies.md) to learn when to use `Screen`, `Region`, image detection, text detection, dynamic scaling, grayscale, and score tuning in more advanced macros. ## How To Use Canonical URL: https://androidmacro.com/docs/basic/how-to-use Markdown URL: https://androidmacro.com/docs/basic/how-to-use.md # How To Use Canonical URL: https://androidmacro.com/docs/basic/how-to-use Source file: /docs/basic/how-to-use.md --- ## Start Macro To run your macro please follow these steps: #### 1. Click the green play button ![Home Page](/img/home-page-1.png) #### 2. To enable clicks, swipes feature and more you have to enable Accessibility Service Permission. ![Home Page](/img/accessibility-service-consent.png) ![Accessibility Service Consent](/img/accessibility-switch.png) #### 3. To enable image/text detection, enable Media Projection Permission. ![Home Page](/img/media-projection-consent.png) After all permission has been granted, the Floating Toolbar will appeared, go back to your macro list and turn switch on to which macro do you want to run. There are 2 types of macro execution, the first one is using code or script and the other one is using blocks. If you are an expertise in coding you can code your self, but if you are not expertise in coding, we provide other method to make macro easily using block editor. Press the play button in Floating Toolbar, and choose which macro execution do you want to run and you are good to go! ![Home Page](/img/toolbar-expanded.png) ## Perform Touch Interaction Canonical URL: https://androidmacro.com/docs/basic/perform-ui-interaction Markdown URL: https://androidmacro.com/docs/basic/perform-ui-interaction.md # Perform Touch Interaction Canonical URL: https://androidmacro.com/docs/basic/perform-ui-interaction Source file: /docs/basic/perform-ui-interaction.md --- There are 3 type of touch interactions in Android Macro ## Clicks To perform tap behaviour in your screen, you can use `Screen:click()` function which is available in `Screen` class. For Example #### Equivalent Code ```js Screen:click(Point(200, 250)) # or Screen:click(200, 250) ``` #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. ## Swipes To perform swipe behaviour in your screen, you can use `Screen:swipe()` function which is available in `Screen` class. The `Screen:swipe()` function requires a list of `SwipePoint(x: int, y: int, holdDuration: int, swipeDuration: int)` #### Equivalent Code ```js Screen:swipe({ SwipePoint(200, 250, 1, 2), SwipePoint(500, 230, 1, 2), }) ``` #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. ## Hold Clicks To perform hold clicks, you can use `Screen:click()` function but this time, we can laveraging the `ClickParams()` function to modify the press and hold duration. For Example #### Equivalent Code ```js Screen:click(Point(200, 250), ClickParams():setDuration(2000)) ``` #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. The `2000` value is the duration of the press in milliseconds. If you run this code/builder, the macro will do hold click at X: 200, Y: 250 with duration press of 2 seconds. ## Wait Until Image or Text Appears or Vanishes Canonical URL: https://androidmacro.com/docs/basic/wait-image-or-text Markdown URL: https://androidmacro.com/docs/basic/wait-image-or-text.md # Wait Until Image or Text Appears or Vanishes Canonical URL: https://androidmacro.com/docs/basic/wait-image-or-text Source file: /docs/basic/wait-image-or-text.md --- In many cases, it's necessary to wait for an image or text to appear or vanish on your screen or within a specific region. This ensures that the text or image you are monitoring is correctly detected or removed before proceeding. For example, if you want to click a button within an app, you need to ensure that the button is visible on your screen. Similarly, if you want to proceed only after a loading icon disappears, you need to wait for it to vanish. ## Waiting for an Image or Text to Appear To wait until a template appears, you can use `Screen:wait(template: string, timeout: number)`. Similar to image detection, you need to pass the template as the text or image name. #### Equivalent Code ```js # wait the button appears Screen:wait('button.jpg', 10000); ``` #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. This macro will wait until "button.jpg" appears on the screen within 10 seconds. If "button.jpg" does not appear within this time, an error will occured. ## Waiting for an Image or Text to Appear To wait until a template vanishes, use `Screen:waitVanish(template: string, timeout: number)`. This function waits for the specified text or image to disappear from the screen. #### Equivalent Code ```js # wait until 'loading_icon.jpg' vanish Screen:waitVanish('loading_icon.jpg', 10000); ``` #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. This macro will wait until "loading_icon.jpg" disappears from the screen within 10 seconds. If the icon is still visible after this time, an error will occured. ## Next Step For more reliable long-running automations, continue with: - [Detection Strategies](../setting/detection-strategies.md) ## Macro Builder Canonical URL: https://androidmacro.com/docs/block-editor Markdown URL: https://androidmacro.com/docs/block-editor.md # Macro Builder Canonical URL: https://androidmacro.com/docs/block-editor Source file: /docs/block-editor/_category_.json --- Learn the most important android macro concepts. ## Pages - [Color](https://androidmacro.com/docs/block-editor/blocks/color.md) - [Dialog](https://androidmacro.com/docs/block-editor/blocks/dialog.md) - [Functions](https://androidmacro.com/docs/block-editor/blocks/functions.md) - [Keyboard](https://androidmacro.com/docs/block-editor/blocks/keyboard.md) - [Loops](https://androidmacro.com/docs/block-editor/blocks/loops.md) - [Math](https://androidmacro.com/docs/block-editor/blocks/math.md) - [Point](https://androidmacro.com/docs/block-editor/blocks/point.md) - [Record](https://androidmacro.com/docs/block-editor/blocks/record.md) - [Region](https://androidmacro.com/docs/block-editor/blocks/region.md) - [Screen](https://androidmacro.com/docs/block-editor/blocks/screen.md) - [Settings](https://androidmacro.com/docs/block-editor/blocks/settings.md) - [System](https://androidmacro.com/docs/block-editor/blocks/system.md) - [Utility](https://androidmacro.com/docs/block-editor/blocks/utility.md) - [Variables](https://androidmacro.com/docs/block-editor/blocks/variables.md) - [Convert Block To Code](https://androidmacro.com/docs/block-editor/convert-block-to-code.md) - [Convert Clicks & Swipes To Block](https://androidmacro.com/docs/block-editor/convert-clicks-swipes-to-blocks.md) - [How To Use](https://androidmacro.com/docs/block-editor/how-to-use.md) - [Region Capture](https://androidmacro.com/docs/block-editor/region-capture.md) ## Blocks Canonical URL: https://androidmacro.com/docs/block-editor/blocks Markdown URL: https://androidmacro.com/docs/block-editor/blocks.md # Blocks Canonical URL: https://androidmacro.com/docs/block-editor/blocks Source file: /docs/block-editor/blocks/_category_.json --- A Block is essentially contains a set of macro instructions, if you combine the block it will make your macro more complex. In this section we will explain the block definition and it's usage that is available within the app, we will not explain all of them, but the one that is commonly used. ## Pages - [Color](https://androidmacro.com/docs/block-editor/blocks/color.md) - [Dialog](https://androidmacro.com/docs/block-editor/blocks/dialog.md) - [Functions](https://androidmacro.com/docs/block-editor/blocks/functions.md) - [Keyboard](https://androidmacro.com/docs/block-editor/blocks/keyboard.md) - [Loops](https://androidmacro.com/docs/block-editor/blocks/loops.md) - [Math](https://androidmacro.com/docs/block-editor/blocks/math.md) - [Point](https://androidmacro.com/docs/block-editor/blocks/point.md) - [Record](https://androidmacro.com/docs/block-editor/blocks/record.md) - [Region](https://androidmacro.com/docs/block-editor/blocks/region.md) - [Screen](https://androidmacro.com/docs/block-editor/blocks/screen.md) - [Settings](https://androidmacro.com/docs/block-editor/blocks/settings.md) - [System](https://androidmacro.com/docs/block-editor/blocks/system.md) - [Utility](https://androidmacro.com/docs/block-editor/blocks/utility.md) - [Variables](https://androidmacro.com/docs/block-editor/blocks/variables.md) ## Color Canonical URL: https://androidmacro.com/docs/block-editor/blocks/color Markdown URL: https://androidmacro.com/docs/block-editor/blocks/color.md # Color Canonical URL: https://androidmacro.com/docs/block-editor/blocks/color Source file: /docs/block-editor/blocks/color.md --- This block's function is to capture a specific pixel on the screen, allowing you to compare the similarity between the snapshot color and a target (mutation) color ## Terminology This module enables color detection, which can be useful for cases where, for example, if a specific coordinate's pixel color matches, you perform action A; otherwise, you perform action B. The comparison method is highly efficient, making it valuable in situations where pixel changes happen quickly and cannot be detected by searching for an image or text. ### Picking a Color Before you can compare the color pixel, you can pick a color using this block, hold down the block and you will see **Pick Color** options. You will enter color picker window, move your finger around to select certain pixel #### Video Example Your browser does not support the video tag. ### Comparing the color After you have successfully pick the color, you can compare and get the comparison value that ranged from 0 to 1. If the value is close to 1 then the both color is highly similar, and vice-versa. #### Video Example Your browser does not support the video tag. ### Comparing using real time pixel color from your screen The question comes in mind. How to get the realtime pixel color so we don't have to select it manually ? Well you can actually do that using this block > Interactive Blockly example omitted in Markdown export. This block will return the color pixel of the selected coordinates, in this example X: 500, Y: 500. It will check the color pixel in your device. After that you can use this block to compare with the color you've picked before, for example **red** color with the color from X: 500, Y: 500 in your screen. > Interactive Blockly example omitted in Markdown export. In the end you will get the comparison score in real-time enabling you to do certain condition, if color pixel in your screen changes ## Dialog Canonical URL: https://androidmacro.com/docs/block-editor/blocks/dialog Markdown URL: https://androidmacro.com/docs/block-editor/blocks/dialog.md # Dialog Canonical URL: https://androidmacro.com/docs/block-editor/blocks/dialog Source file: /docs/block-editor/blocks/dialog.md --- This block enables you to create a dialog popup for the macro user ## Terminology The `Dialog` block lets you create a popup window to interact with users in your macro. For more complex macros, this can be useful for getting input from the user before starting. By gathering information upfront, the macro can adjust its behavior based on the user’s choices. ### Initialize the dialog To use a Dialog block, start by using this block, which prepares the dialog for setup. > Interactive Blockly example omitted in Markdown export. ### Adding Components to the dialog Once dialog has been initialize, you can insert some dialog components block into the dialog. Currently dialog only accept these components **CheckBox**, **TextView**, **Radio Button**, **Radio Group**, **Column**, **Row** and **Text Input** Some dialog components also support default values through the block mutator: - `Text Input` can define default text - `CheckBox` can define default checked state - `Radio Group` can define a default option id ![Dialog Explanation](/img/dialog-explanation.jpg) #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. ### Extract the user input from dialog To grab user input, you can use this block to grab the value based on the dialog component id ![Extract Dialog Component Value](/img/extract-dialog-input-example.jpg) In this example we extract the value of component id `5` which is the CheckBox and assign it to variable `value`. The `value` will receive boolean data types ### Auto confirm with timeout The dialog show block also supports an optional timeout through its mutator. When the timeout is set, the dialog will automatically confirm after the specified number of milliseconds and continue macro execution with the current or default values. #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. ## Functions Canonical URL: https://androidmacro.com/docs/block-editor/blocks/functions Markdown URL: https://androidmacro.com/docs/block-editor/blocks/functions.md # Functions Canonical URL: https://androidmacro.com/docs/block-editor/blocks/functions Source file: /docs/block-editor/blocks/functions.md --- Functions in Android Macro are reusable pieces of code that perform specific tasks. They allow you to organize your code into manageable chunks and avoid repetition. ## Why Use Functions? - **Reusability**: Write code once, use it multiple times. - **Organization**: Keep your code clean and structured. - **Simplification**: Break complex problems into smaller, manageable parts. ## Types of Function Blocks ### 1. Function Definition Block This block defines a new function. ![Function call](/img/function-definition.png) - Give your function a name - Add input parameters if needed - Build the function's logic inside - Return a value if necessary ### 2. Function Call Block This block calls (uses) a function you've defined. ![Function call](/img/function-call.png) - Select the function you want to use - Provide any required input values ## How to Use Functions 1. **Define your function**: - Drag a function definition block into your workspace - Name your function - Add any necessary input parameters - Build the function's logic using other blocks 2. **Use your function**: - Drag a function call block where you want to use the function - Select your function from the dropdown menu - Provide any required input values ## Example: Creating and Using a Simple Function Let's create a function that says "Hello" to someone: 1. **Define the function**: ![Function definition example](/img/function-definition-example.png) 2. **Use the function**: ![Function call example](/img/function-call-example.png) This function takes a name as input and displays a greeting message. ## Tips for Using Functions - Use clear, descriptive names for your functions - Keep functions focused on a single task - Use input parameters to make functions more flexible - Test your functions to ensure they work as expected Functions are powerful tools in Android Macro that can help you create more organized and efficient code. Practice using them to create your own macro! ## Keyboard Canonical URL: https://androidmacro.com/docs/block-editor/blocks/keyboard Markdown URL: https://androidmacro.com/docs/block-editor/blocks/keyboard.md # Keyboard Canonical URL: https://androidmacro.com/docs/block-editor/blocks/keyboard Source file: /docs/block-editor/blocks/keyboard.md --- A block for simulating keyboard press, in certain scenario you might need to input some text into certain app. It utilizes clipboard mechanism to mimic the same behaviour as typing, so it will copy a text and then paste it into input box ## How to simulate keyboard press To perform keybord press, it's straight forward you just need to use this block > Interactive Blockly example omitted in Markdown export. #### Video Example Your browser does not support the video tag. ## Loops Canonical URL: https://androidmacro.com/docs/block-editor/blocks/loops Markdown URL: https://androidmacro.com/docs/block-editor/blocks/loops.md # Loops Canonical URL: https://androidmacro.com/docs/block-editor/blocks/loops Source file: /docs/block-editor/blocks/loops.md --- Loops in Android Macro allow you to repeat a set of actions multiple times. They are essential for automating repetitive tasks efficiently. ## Types of Loops ### 1. Repeat Loop The repeat loop executes a set of blocks a specific number of times. > Interactive Blockly example omitted in Markdown export. - Specify how many times you want the actions to repeat - The blocks inside will execute that exact number of times ### 2. While Loop The while loop continues executing as long as a condition remains true. > Interactive Blockly example omitted in Markdown export. - The loop checks the condition before each iteration - Actions inside repeat until the condition becomes false - Be careful to ensure the condition will eventually become false to avoid infinite loops ### 3. For Loop The for loop is useful when you want to count through a range of numbers. > Interactive Blockly example omitted in Markdown export. - Specify the start number, end number, and step size - The counter variable can be used inside the loop - Useful for tasks that need to track progress ## Example: Using a Repeat Loop Here's an example of using a repeat loop to tap the screen 5 times: > Interactive Blockly example omitted in Markdown export. ## Tips for Using Loops - Choose the appropriate type of loop for your task - Be careful with infinite loops - ensure there's a way for the loop to end - Use variables to track the state within loops when needed - Consider using wait blocks between iterations if needed - Test your loops with small numbers first before increasing iterations Loops are powerful tools that can save you time by automating repetitive tasks. Practice using different types of loops to create more efficient macros! ## Math Canonical URL: https://androidmacro.com/docs/block-editor/blocks/math Markdown URL: https://androidmacro.com/docs/block-editor/blocks/math.md # Math Canonical URL: https://androidmacro.com/docs/block-editor/blocks/math Source file: /docs/block-editor/blocks/math.md --- Math blocks in Android Macro allow you to perform mathematical calculations and operations within your macros. ## Types of Math Operations ### 1. Basic Arithmetic Basic arithmetic operations include addition, subtraction, multiplication, and division. > Interactive Blockly example omitted in Markdown export. - Addition (+) - Subtraction (-) - Multiplication (×) - Division (÷) - Power (^) ### 2. Number Block Use this block to input specific numbers into your calculations. > Interactive Blockly example omitted in Markdown export. ### 3. Math Functions Advanced mathematical operations and functions. > Interactive Blockly example omitted in Markdown export. - Square root - Absolute value - Negative value - Natural logarithm - Power of e - Base 10 logarithm ### 4. Rounding Functions Different ways to round numbers. > Interactive Blockly example omitted in Markdown export. - Round - Round up (ceiling) - Round down (floor) ## Example: Basic Calculation Here's an example of performing a basic calculation (2 + 3) × 4: > Interactive Blockly example omitted in Markdown export. ## Tips for Using Math Blocks - Use parentheses to control the order of operations - Test calculations with simple numbers first - Remember that division by zero will cause errors - Use rounding when dealing with decimal numbers that need to be precise - Consider using variables to store intermediate results in complex calculations Math blocks are essential tools for creating macros that need to perform calculations or work with numerical data. They can be combined with other blocks to create more complex and powerful automation scripts. ## Point Canonical URL: https://androidmacro.com/docs/block-editor/blocks/point Markdown URL: https://androidmacro.com/docs/block-editor/blocks/point.md # Point Canonical URL: https://androidmacro.com/docs/block-editor/blocks/point Source file: /docs/block-editor/blocks/point.md --- Points in Android Macro are fundamental building blocks used to specify screen coordinates and gesture parameters. There are two types of points available: basic Points and SwipePoints. ## Types of Points ### 1. Basic Point A basic Point represents a single location on the screen using x and y coordinates. > Interactive Blockly example omitted in Markdown export. Parameters: - x: The horizontal coordinate (pixels from left) - y: The vertical coordinate (pixels from top) Basic Points are commonly used with click operations: > Interactive Blockly example omitted in Markdown export. ### 2. SwipePoint A SwipePoint extends the basic Point with additional parameters for gesture control. > Interactive Blockly example omitted in Markdown export. Parameters: - x: The horizontal coordinate (pixels from left) - y: The vertical coordinate (pixels from top) - holdDuration: How long to hold before starting the swipe (milliseconds) - swipeDuration: How long the swipe motion should take (milliseconds) SwipePoints are used in pairs to define swipe gestures: > Interactive Blockly example omitted in Markdown export. ## Tips for Using Points - Use screen coordinates that are appropriate for your device's resolution - For swipes, ensure the holdDuration and swipeDuration are long enough to be recognized - Test points with different coordinate values to ensure reliability - Consider using variables to store frequently used points - Remember that (0,0) is at the top-left corner of the screen ## Record Canonical URL: https://androidmacro.com/docs/block-editor/blocks/record Markdown URL: https://androidmacro.com/docs/block-editor/blocks/record.md # Record Canonical URL: https://androidmacro.com/docs/block-editor/blocks/record Source file: /docs/block-editor/blocks/record.md --- Introduced in version 1.0.0.16, this block enables the replay of recorded gestures or touch actions. It is particularly useful for automating complex interactions, such as sequences of swipes and clicks, that are difficult to manage manually. ### Block Input - **Gesture Name**: The name of the gesture to be replayed. This is selected from a dropdown list of previously recorded gestures. - **Speed**: The speed at which the gesture should be replayed. This is a numeric value that can be adjusted to speed up or slow down the gesture. - **Delay**: The delay between each action in the gesture sequence, specified in milliseconds. ### Example Here is an example of how to use the `Record` block in a Android Macro: > Interactive Blockly example omitted in Markdown export. ### Video Example Your browser does not support the video tag. ## Region Canonical URL: https://androidmacro.com/docs/block-editor/blocks/region Markdown URL: https://androidmacro.com/docs/block-editor/blocks/region.md # Region Canonical URL: https://androidmacro.com/docs/block-editor/blocks/region Source file: /docs/block-editor/blocks/region.md --- Regions in Android Macro allow you to define specific areas on the screen for interaction and recognition. They are useful for limiting where the macro searches for templates or performs actions. ## Types of Regions ### 1. Basic Region A basic Region defines a rectangular area using x, y coordinates and width, height dimensions. > Interactive Blockly example omitted in Markdown export. Parameters: - x: The horizontal coordinate of the top-left corner - y: The vertical coordinate of the top-left corner - width: The width of the region in pixels - height: The height of the region in pixels ### 2. Using Regions Regions can be used to: - Restrict template matching to a specific area - Define clickable zones - Create boundaries for swipe gestures - Optimize performance by reducing the search area ## Example: Template Matching in Region Here's an example of searching for a template within a defined region: > Interactive Blockly example omitted in Markdown export. ## Tips for Using Regions - Use regions to improve macro performance by limiting search areas - Make regions slightly larger than needed to account for screen variations - Consider device resolution when defining region dimensions - Test regions with different screen orientations - Use variables to store frequently used regions ## Screen Canonical URL: https://androidmacro.com/docs/block-editor/blocks/screen Markdown URL: https://androidmacro.com/docs/block-editor/blocks/screen.md # Screen Canonical URL: https://androidmacro.com/docs/block-editor/blocks/screen Source file: /docs/block-editor/blocks/screen.md --- The Screen module is used for performing UI automation tasks such as checking the presence of templates or text, performing clicks, and swiping on the screen. ### 1. How to check template exist in the screen > Interactive Blockly example omitted in Markdown export. This method returns a boolean value. If true, then the template you are searching for currently exists on your device screen. Before using this block, please make sure to capture the image template that you need to perform the search for. #### Video Example Your browser does not support the video tag. ### 2. How to check certain text exist in the screen > Interactive Blockly example omitted in Markdown export. This method returns a boolean value. If true, then the text you are searching for currently exists on your device screen. You don't need to capture an image, just specify the text you want to search for. Note that this block will detect text using a case-insensitive comparison, and if the text contains a substring, it will also be considered a match. #### Video Example Your browser does not support the video tag. ### 3. How to perform image detection click > Interactive Blockly example omitted in Markdown export. This block will execute click using image detection based on template drop down list, this is useful when the search template is constantly moving in your screen #### Video Example Your browser does not support the video tag. ### 4. How to perform click & hold click > Interactive Blockly example omitted in Markdown export. This is a basic and commonly used block to perform clicks. You can customize the click parameters such as how long it will press the coordinate, delay, and offset. To customize the behaviour you can click the gear button at the top left of the block #### Video Example Your browser does not support the video tag. ### 5. How to perform swipe > Interactive Blockly example omitted in Markdown export. This block allows you to perform a swipe action by specifying multiple coordinates. You can customize the swipe parameters such as the hold duration and speed for each point. To modify the swipe coordinates, you can hold this block inside your workspace, and a dialog popup window will appear, click "Edit coordinates", and click check button to change the coordinates #### Video Example Your browser does not support the video tag. ## Settings Canonical URL: https://androidmacro.com/docs/block-editor/blocks/settings Markdown URL: https://androidmacro.com/docs/block-editor/blocks/settings.md # Settings Canonical URL: https://androidmacro.com/docs/block-editor/blocks/settings Source file: /docs/block-editor/blocks/settings.md --- The Settings module provides various configuration options to control how your macro behaves. Here are the key features: ## Detection Settings ### Minimum Score - `Settings:getMinScore()` - Get the current minimum threshold score for text/image detection - `Settings:setMinScore(score: number)` - Set the minimum threshold score for detection ### Grayscale Mode - `Settings:isGrayscale()` - Check if grayscale mode is enabled - `Settings:grayscaleOn()` - Enable grayscale mode for faster detection - `Settings:grayscaleOff()` - Disable grayscale mode ### Template Caching - `Settings:cacheOn()` - Enable template caching to improve performance - `Settings:cacheOff()` - Disable template caching ## Delay Settings ### Click Delay - `Settings:getClickDelay()` - Get the current click delay - `Settings:setClickDelay(delayMs: number)` - Set the delay between click actions ### Swipe Delay - `Settings:getSwipeDelay()` - Get the current swipe delay - `Settings:setSwipeDelay(delayMs: number)` - Set the delay between swipe actions ### Scan Interval - `Settings:getScanInterval()` - Get the current scan interval for detection - `Settings:setScanInterval(interval: number)` - Set the delay between detection scans ## Example Usage ```js // Configure detection settings Settings:setMinScore(0.8); Settings:grayscaleOn(); Settings:cacheOn(); // Configure delays Settings:setClickDelay(500); Settings:setSwipeDelay(1000); Settings:setScanInterval(200); // Get current settings minScore = Settings:getMinScore(); isGray = Settings:isGrayscale(); clickDelay = Settings:getClickDelay(); ``` ## Block Configuration > Interactive Blockly example omitted in Markdown export. ### Detection Settings - **Minimum Score**: Set the threshold score (0-1) for text and image detection - **Grayscale Mode**: Toggle grayscale processing for faster detection - **Template Cache**: Enable/disable template caching to optimize performance ### Delay Settings - **Click Delay**: Set the delay between click actions (in milliseconds) - **Swipe Delay**: Set the delay between swipe actions (in milliseconds) - **Scan Interval**: Set the delay between detection scans (in milliseconds) ## Example ## Usage Tips 1. **Performance Optimization** - Enable grayscale mode when color isn't important for detection - Use template caching when working with static screens - Adjust scan intervals based on your device's capabilities 2. **Timing Adjustments** - Increase delays on slower devices - Use shorter delays for time-critical operations - Balance speed vs reliability 3. **Detection Tuning** - Higher minimum scores (closer to 1) for more precise matching - Lower scores (closer to 0) for more flexible matching - Start with 0.8 and adjust as needed ## Related Blocks - Image Detection - Text Detection - Click - Swipe ## System Canonical URL: https://androidmacro.com/docs/block-editor/blocks/system Markdown URL: https://androidmacro.com/docs/block-editor/blocks/system.md # System Canonical URL: https://androidmacro.com/docs/block-editor/blocks/system Source file: /docs/block-editor/blocks/system.md --- The System module provides blocks for interacting with Android system buttons. These blocks allow you to programmatically press the back, home, and recent apps buttons. ## Available Blocks ### Press Back Button Simulates pressing the device's back button. This is equivalent to calling `System:back()`. > Interactive Blockly example omitted in Markdown export. ### Press Home Button Simulates pressing the device's home button. This is equivalent to calling `System:home()`. > Interactive Blockly example omitted in Markdown export. ### Press Recent Apps Button Simulates pressing the device's recent apps button. This is equivalent to calling `System:recent()`. > Interactive Blockly example omitted in Markdown export. ## Example Usage Here's an example of using system blocks to navigate through apps: > Interactive Blockly example omitted in Markdown export. ## Utility Canonical URL: https://androidmacro.com/docs/block-editor/blocks/utility Markdown URL: https://androidmacro.com/docs/block-editor/blocks/utility.md # Utility Canonical URL: https://androidmacro.com/docs/block-editor/blocks/utility Source file: /docs/block-editor/blocks/utility.md --- The Utility blocks provide helpful functions for controlling flow and displaying information in your macros. ## Alert Shows an alert message to the screen with an optional title. ![Home Page](/img/alert-example.jpg) **Inputs:** - Message (string): The message to display - Title (string): Optional title for the alert box > Interactive Blockly example omitted in Markdown export. ## Sleep Pauses the macro execution for a specified amount of time. ![Home Page](/img/sleep.jpg) **Inputs:** - Milliseconds (number): The duration to pause in milliseconds (1000ms = 1 second) > Interactive Blockly example omitted in Markdown export. ## Variables Canonical URL: https://androidmacro.com/docs/block-editor/blocks/variables Markdown URL: https://androidmacro.com/docs/block-editor/blocks/variables.md # Variables Canonical URL: https://androidmacro.com/docs/block-editor/blocks/variables Source file: /docs/block-editor/blocks/variables.md --- Variables in Android Macro allow you to store and reuse values throughout your automation script. They act like containers that can hold different types of data like screen coordinates, text to type, or detection results. ## Creating Variables To create a variable: 1. Click the "Variables" category in the toolbox 2. Click "Create variable" 3. Enter a descriptive name for your automation needs 4. Click "OK" > Interactive Blockly example omitted in Markdown export. ## Using Variables in Macros ### Store Detection Results Use variables to save results from screen detection for later use: > Interactive Blockly example omitted in Markdown export. ### Save Coordinates Store screen coordinates to reuse in multiple clicks: > Interactive Blockly example omitted in Markdown export. ## Common Variable Uses in Android Macro Variables are especially useful for: - Storing screen coordinates for repeated taps - Saving detection results (whether an image/text exists) - Counting iterations in automation loops - Storing text to type into applications - Saving color detection results - Managing timing delays between actions ## Example: Click Counter Here's a practical example that counts successful clicks in your macro: > Interactive Blockly example omitted in Markdown export. ## Tips for Android Macro Variables - Use variables to store detection results before making decisions - Save frequently used coordinates in variables for cleaner code - Initialize counters to track automation progress - Use descriptive names like `login_button_x` or `menu_exists` - Variables can make your macro more reliable by storing and checking states Variables are essential for creating smart, adaptive macros that can handle different scenarios and maintain state throughout the automation process. ## Convert Block To Code Canonical URL: https://androidmacro.com/docs/block-editor/convert-block-to-code Markdown URL: https://androidmacro.com/docs/block-editor/convert-block-to-code.md # Convert Block To Code Canonical URL: https://androidmacro.com/docs/block-editor/convert-block-to-code Source file: /docs/block-editor/convert-block-to-code.md --- In floating builder, you can convert your workspace into code if you need to see what's the block executing. This is best if you try it out your self. To convert blocks into code, follow these steps: 1. Open the floating toolbar. 2. Open Floating Builder. 3. Click the circle arrow-shaped icon. 4. Press OK. 5. Go back to your macro list and press the code-shaped icon. You will see the generated code of your workspace. ## Convert Clicks & Swipes To Block Canonical URL: https://androidmacro.com/docs/block-editor/convert-clicks-swipes-to-blocks Markdown URL: https://androidmacro.com/docs/block-editor/convert-clicks-swipes-to-blocks.md # Convert Clicks & Swipes To Block Canonical URL: https://androidmacro.com/docs/block-editor/convert-clicks-swipes-to-blocks Source file: /docs/block-editor/convert-clicks-swipes-to-blocks.md --- In some cases, you might need to perform clicks and swipes on your screen. But how do you get the coordinates? You can use this utility feature to get the coordinates instead of inserting them manually. To convert clicks and swipes into blocks, follow these steps: 1. Open the floating toolbar. 2. Open Floating Builder. 3. Click the gesture-shaped icon. 4. In this window, you can add point and swipe indicators as many as you want. 5. After you have placed the indicators on the screen, press the check icon. 6. The blocks will appear in Floating Builder. Once the blocks appear in Floating Builder, you can use them to perform the clicks or swipes. ### Video Example Your browser does not support the video tag. ## How To Use Canonical URL: https://androidmacro.com/docs/block-editor/how-to-use Markdown URL: https://androidmacro.com/docs/block-editor/how-to-use.md # How To Use Canonical URL: https://androidmacro.com/docs/block-editor/how-to-use Source file: /docs/block-editor/how-to-use.md --- In this section we will explain how to use macro builder or block editor. This feature will essentially make your macro development more easier, to start off you need to run Toolbar Service or you can access it on "My Macros" tab. ![Home Page](/img/access-builder-editor-button.png) If you open the macro builder, you will see this screen. ![Home Page](/img/builder-editor.png) In the sidebar left, there are a lot of list item, we called it "Module" or "Class". Each module contains block component that can be used for macro development. The code blocks inside macro builder will be executed from top to bottom Once you have made changes, hit save and close the builder editor ![image](/img/save-and-exit-block-editor.png) After that you can test your macro using "Play Blocks" in Toolbar Service to see if it's working or not ![image](/img/play-block.png) ## Region Capture Canonical URL: https://androidmacro.com/docs/block-editor/region-capture Markdown URL: https://androidmacro.com/docs/block-editor/region-capture.md # Region Capture Canonical URL: https://androidmacro.com/docs/block-editor/region-capture Source file: /docs/block-editor/region-capture.md --- Region capture, or region of interest, is simply an area for detection instead of running on your entire screen. If the template or text you want to detect always exists in a certain region, you might use this function. There are numerous benefits to using this method, and it is also more performant. To use region capture you can follow these steps: 1. Open floating toolbar 2. Click block shaped icon 3. Click rectangle shaped icon 4. Select the region of interest by dragging the red rectangle corner ### Video Example Your browser does not support the video tag. ## Conditional Canonical URL: https://androidmacro.com/docs/conditional Markdown URL: https://androidmacro.com/docs/conditional.md # Conditional Canonical URL: https://androidmacro.com/docs/conditional Source file: /docs/conditional/_category_.json --- Learn the most important android macro concepts. ## Pages - [If, Else If, Else](https://androidmacro.com/docs/conditional/if-else.md) ## If, Else If, Else Canonical URL: https://androidmacro.com/docs/conditional/if-else Markdown URL: https://androidmacro.com/docs/conditional/if-else.md # If, Else If, Else Canonical URL: https://androidmacro.com/docs/conditional/if-else Source file: /docs/conditional/if-else.md --- In Android Macro, conditional statements are used to perform different actions based on different conditions. The most common form of conditional statements are the `if`, `else if`, and `else` statements. ## If Statement The `if` statement is used to execute a block of code only if a specified condition is true. > Interactive Blockly example omitted in Markdown export. The example above shows a basic if statement that: 1. Checks if an image exists on screen 2. If true, performs a click action at coordinates (500,500) ## Else If Statement The `else if` statement allows you to test multiple conditions in sequence. > Interactive Blockly example omitted in Markdown export. In this example: 1. First condition is checked 2. If false, second condition is checked 3. Different actions are performed based on which condition is true ## Else Statement The `else` statement executes when none of the previous conditions are true. > Interactive Blockly example omitted in Markdown export. This example shows: 1. Checking for an image 2. Showing one alert if found 3. Showing a different alert if not found ## Common Uses Conditional statements are useful for: - Checking if elements exist before interacting with them - Creating different paths based on screen states - Handling errors and edge cases - Making macros more robust and adaptable ## Tips - Always test your conditions thoroughly - Use clear, logical conditions - Consider all possible scenarios - Add appropriate delays when needed - Use else statements as fallbacks ## Dialog Builder Canonical URL: https://androidmacro.com/docs/dialog-builder Markdown URL: https://androidmacro.com/docs/dialog-builder.md # Dialog Builder Canonical URL: https://androidmacro.com/docs/dialog-builder Source file: /docs/dialog-builder/_category_.json --- Learn how to build your own dialog ## Pages - [Definition](https://androidmacro.com/docs/dialog-builder/definition.md) - [How To Build Dialog Prompt](https://androidmacro.com/docs/dialog-builder/how-to-build-dialog.md) ## Definition Canonical URL: https://androidmacro.com/docs/dialog-builder/definition Markdown URL: https://androidmacro.com/docs/dialog-builder/definition.md # Definition Canonical URL: https://androidmacro.com/docs/dialog-builder/definition Source file: /docs/dialog-builder/definition.md --- # Dialog Builder ## What Is Dialog Builder? Dialog Builder is a useful feature that allows you to create interactive dialogs within your macro. These dialogs are typically used to gather input from users before the macro begins its main execution. Think of it as a way to customize your macro's behavior based on user choices. For example, you could create a dialog that asks, "Which option would you like to run?" If the user selects option 5, the macro would then perform a specific set of actions associated with that choice. ## Dialog Components Dialogs are constructed using various UI components. Each dialog can include the following elements: 1. CheckBox: For yes/no or true/false selections 2. EditText: For free-form text input 3. RadioGroup: A container for multiple RadioButtons 4. Column: A vertical layout container 5. Row: A horizontal layout container 6. RadioButton: For single-choice selections within a RadioGroup 7. TextView: For displaying text information ## Default Values Dialog input components can now define initial values before the dialog is shown: - `EditText(id, hint, defaultValue)` sets the starting text - `CheckBox(id, text, defaultChecked)` sets the starting checked state - `RadioGroup(id, defaultButtonId)` selects a radio button by default When a default value is provided, it is used first when the dialog opens. ## Building Your Dialog You can combine these components to create a custom dialog that suits your macro's needs. Among these components, there are three input types from which you can retrieve values: - CheckBox - EditText - RadioGroup To access the values from these input components, you can use the `Dialog:getValueById()` function in your macro logic. By specifying the component's unique ID, you can retrieve the user's input and use it to guide your macro's actions. **Note**: Each component in your dialog must have a unique ID. This ensures that the macro can correctly identify and retrieve values from the specific component you're targeting. Duplicate IDs may lead to confusion and errors in your macro's execution. ## How To Build Dialog Prompt Canonical URL: https://androidmacro.com/docs/dialog-builder/how-to-build-dialog Markdown URL: https://androidmacro.com/docs/dialog-builder/how-to-build-dialog.md # How To Build Dialog Prompt Canonical URL: https://androidmacro.com/docs/dialog-builder/how-to-build-dialog Source file: /docs/dialog-builder/how-to-build-dialog.md --- ### Initialize the dialog To use a Dialog block, start by using this block, which prepares the dialog for setup. > Interactive Blockly example omitted in Markdown export. ### Adding Components to the dialog Once dialog has been initialize, you can insert some dialog components block into the dialog. Currently dialog only accept these components **CheckBox**, **TextView**, **Radio Button**, **Radio Group**, **Column**, **Row** and **Text Input** Some dialog components also support default values through the block mutator: - `Text Input` can define default text - `CheckBox` can define default checked state - `Radio Group` can define a default option id ![Dialog Explanation](/img/dialog-explanation.jpg) #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. ### Extract the user input from dialog To grab user input, you can use this block to grab the value based on the dialog component id ![Extract Dialog Component Value](/img/extract-dialog-input-example.jpg) In this example we extract the value of component id `5` which is the CheckBox and assign it to variable `value`. The `value` will receive boolean data types ### Auto confirm with timeout The dialog show block also supports an optional timeout through its mutator. When the timeout is set, the dialog will automatically confirm after the specified number of milliseconds and continue macro execution with the current or default values. #### Equivalent Block Builder > Interactive Blockly example omitted in Markdown export. ## Function & Variables Canonical URL: https://androidmacro.com/docs/function Markdown URL: https://androidmacro.com/docs/function.md # Function & Variables Canonical URL: https://androidmacro.com/docs/function Source file: /docs/function/_category_.json --- Learn Android Macro function & variables to create a reliable & reusable piece of code/block ## Pages - [Functions](https://androidmacro.com/docs/function/functions.md) - [Variables](https://androidmacro.com/docs/function/variables.md) ## Functions Canonical URL: https://androidmacro.com/docs/function/functions Markdown URL: https://androidmacro.com/docs/function/functions.md # Functions Canonical URL: https://androidmacro.com/docs/function/functions Source file: /docs/function/functions.md --- ## What Are Functions? Functions in Android Macro are reusable pieces of code that perform specific tasks. They allow you to organize your code into manageable chunks and avoid repetition. ## Why Use Functions? - **Reusability**: Write code once, use it multiple times. - **Organization**: Keep your code clean and structured. - **Simplification**: Break complex problems into smaller, manageable parts. ## Types of Function Blocks ### 1. Function Definition Block This block defines a new function. ![Function call](/img/function-definition.png) - Give your function a name - Add input parameters if needed - Build the function's logic inside - Return a value if necessary ### 2. Function Call Block This block calls (uses) a function you've defined. ![Function call](/img/function-call.png) - Select the function you want to use - Provide any required input values ## How to Use Functions 1. **Define your function**: - Drag a function definition block into your workspace - Name your function - Add any necessary input parameters - Build the function's logic using other blocks 2. **Use your function**: - Drag a function call block where you want to use the function - Select your function from the dropdown menu - Provide any required input values ## Example: Creating and Using a Simple Function Let's create a function that says "Hello" to someone: 1. **Define the function**: ![Function definition example](/img/function-definition-example.png) 2. **Use the function**: ![Function call example](/img/function-call-example.png) This function takes a name as input and displays a greeting message. ## Tips for Using Functions - Use clear, descriptive names for your functions - Keep functions focused on a single task - Use input parameters to make functions more flexible - Test your functions to ensure they work as expected Functions are powerful tools in Android Macro that can help you create more organized and efficient code. Practice using them to create your own macro! ## Variables Canonical URL: https://androidmacro.com/docs/function/variables Markdown URL: https://androidmacro.com/docs/function/variables.md # Variables Canonical URL: https://androidmacro.com/docs/function/variables Source file: /docs/function/variables.md --- Variables are essential components in Android Macro that allow you to store and manipulate data. Variables are represented visually, making them easier to understand and use. ## What are Variables? A variable is like a container that holds a piece of information. This information can be a number, text, or other types of data. You can think of a variable as a labeled box where you can put something and retrieve it later. ## Why Use Variables? Variables are powerful because they allow your macro to: - **Store information**: Keep track of data throughout your macro. - **Update information**: Change the stored data as your macro runs. - **Reuse information**: Use the same data in multiple parts of your macro. ## Creating Variables To create a variable: 1. Look for the "Variables" category in the toolbox. 2. Click on "Create variable..." 3. Enter a name for your variable. 4. Click "OK" to create the variable. Once created, you'll see new blocks appear in the "Variables" category for using your variable. ![Variable example](/img/variable-example.png) ## Using Variables Android Macro provides several blocks for working with variables: - **Set variable**: This block lets you assign a value to a variable. - **Get variable**: This block retrieves the current value of a variable. - **Change variable**: This block increases or decreases a numeric variable by a specified amount. ## Example: Using Variables Let's walk through a simple example of using variables: 1. Create a variable called "score". 2. Use the "set variable" block to set "score" to 0. 3. Use the "change variable" block to increase "score" by 1. 4. Use the "get variable" block to display the current value of "score". This sequence would look something like this: ![Variable example](/img/variable-example-1.png) ## Best Practices for Variables - **Use descriptive names**: Name your variables clearly so you remember what they represent (e.g., "playerScore" instead of just "s"). - **Initialize variables**: Always give your variables a starting value. - **Use the right type**: Make sure you're storing the right kind of data in your variable (e.g., numbers for scores, text for names). Variables are a fundamental concept in Android Macro, and Android Macro makes them accessible through its visual interface. By understanding how to create and use variables, you're taking an important step in learning to code! ## How Does It Work Canonical URL: https://androidmacro.com/docs/how-does-it-work Markdown URL: https://androidmacro.com/docs/how-does-it-work.md # How Does It Work Canonical URL: https://androidmacro.com/docs/how-does-it-work Source file: /docs/how-does-it-work.md --- Automating repetitive tasks on your mobile device can save you a significant amount of time and effort. There are many tools available that possess great capabilities to perform simple or complex auto-clicking tasks. Android Macro is one such app that utilizes the Accessibility Service and Screen Recording functionality of Android devices. However, what sets it apart is its smart intuition. This app can detect text or a subset of an image on your screen, which is typically referred to as a template. The process of identifying these templates is known as Template Matching. To maximize the detection accuracy, Android Macro also uses Optical Character Recognition (OCR) technology. This allows the app to not only recognize images but also text within those images, providing a more comprehensive and reliable detection capability. Once a template or text is detected, Android Macro can automate various actions based on your preferences. For instance, it can simulate taps, swipes, or even input text, mimicking human interaction with the device. This automation can be particularly useful for tasks that involve repetitive steps, such as filling out forms, navigating through menus, or performing routine actions in games or productivity apps. With its intelligent template matching and OCR capabilities, Android Macro offers a powerful solution for streamlining your workflows and saving valuable time. Whether you need to automate simple or complex tasks, this app provides a user-friendly interface and robust features to cater to your automation needs. ## Lists Canonical URL: https://androidmacro.com/docs/lists Markdown URL: https://androidmacro.com/docs/lists.md # Lists Canonical URL: https://androidmacro.com/docs/lists Source file: /docs/lists/_category_.json --- Blocks for managing collections of items. ## Pages - [Accessing Items](https://androidmacro.com/docs/lists/access.md) - [Creating Lists](https://androidmacro.com/docs/lists/creation.md) - [Managing Items](https://androidmacro.com/docs/lists/management.md) - [List Operations](https://androidmacro.com/docs/lists/operations.md) - [Getting Sublists](https://androidmacro.com/docs/lists/sublists.md) ## Accessing Items Canonical URL: https://androidmacro.com/docs/lists/access Markdown URL: https://androidmacro.com/docs/lists/access.md # Accessing Items Canonical URL: https://androidmacro.com/docs/lists/access Source file: /docs/lists/access.md --- ## Length of List Returns the number of items in the list. > Interactive Blockly example omitted in Markdown export. ## Is Empty? Checks if the list has no items. > Interactive Blockly example omitted in Markdown export. ## Find Item Finds the position of an item in the list. > Interactive Blockly example omitted in Markdown export. - Returns 0 if not found. ## Creating Lists Canonical URL: https://androidmacro.com/docs/lists/creation Markdown URL: https://androidmacro.com/docs/lists/creation.md # Creating Lists Canonical URL: https://androidmacro.com/docs/lists/creation Source file: /docs/lists/creation.md --- ## Create Empty List Creates a new list with no items. > Interactive Blockly example omitted in Markdown export. ## Create List With Creates a list with specific initial items. > Interactive Blockly example omitted in Markdown export. - Click the gear icon to add more items. ## Create List with Item Repeated Creates a list of a certain size, filled with the same item. > Interactive Blockly example omitted in Markdown export. - Example: `[0, 0, 0, 0, 0]` ## Managing Items Canonical URL: https://androidmacro.com/docs/lists/management Markdown URL: https://androidmacro.com/docs/lists/management.md # Managing Items Canonical URL: https://androidmacro.com/docs/lists/management Source file: /docs/lists/management.md --- ## Get / Remove Item Gets or removes an item at a specific position. > Interactive Blockly example omitted in Markdown export. ### Modes - **Get**: Returns the item without changing the list. - **Get and Remove**: Returns the item and deletes it from the list. - **Remove**: Deletes the item (no return value). ### Locations - **#**: Specific index (starts at 1). - **# from end**: Index counting from the back. - **First / Last**: The first or last item. - **Random**: A random item. ## Set / Insert Item Changes an item or adds a new one at a specific position. > Interactive Blockly example omitted in Markdown export. - **Set**: Overwrites the existing item. - **Insert**: Adds a new item, shifting others down. ## List Operations Canonical URL: https://androidmacro.com/docs/lists/operations Markdown URL: https://androidmacro.com/docs/lists/operations.md # List Operations Canonical URL: https://androidmacro.com/docs/lists/operations Source file: /docs/lists/operations.md --- ## Split Text into List Splits a text string into a list of pieces. > Interactive Blockly example omitted in Markdown export. - **Input**: "a,b,c" - **Delimiter**: "," - **Result**: `['a', 'b', 'c']` ## Join List into Text Combines a list of items into a single text string. > Interactive Blockly example omitted in Markdown export. - **Input**: `['a', 'b', 'c']` - **Delimiter**: "-" - **Result**: "a-b-c" ## Sort List Sorts the items in a list (numerically or alphabetically). > Interactive Blockly example omitted in Markdown export. - **Type**: Numeric, Text, or Case-insensitive Text. - **Direction**: Ascending (A-Z, 0-9) or Descending (Z-A, 9-0). ## Getting Sublists Canonical URL: https://androidmacro.com/docs/lists/sublists Markdown URL: https://androidmacro.com/docs/lists/sublists.md # Getting Sublists Canonical URL: https://androidmacro.com/docs/lists/sublists Source file: /docs/lists/sublists.md --- # Getting a Sublist Extracts a portion of a list to create a new list. > Interactive Blockly example omitted in Markdown export. - Creates a new list containing items from the *Start* position to the *End* position (inclusive). - **Example**: Getting items 1 to 3 from `['a', 'b', 'c', 'd']` returns `['a', 'b', 'c']`. ## Logic Canonical URL: https://androidmacro.com/docs/logic Markdown URL: https://androidmacro.com/docs/logic.md # Logic Canonical URL: https://androidmacro.com/docs/logic Source file: /docs/logic/_category_.json --- Logic blocks for controlling flow and making decisions. ## Pages - [Boolean Logic](https://androidmacro.com/docs/logic/boolean.md) - [Logic Comparisons](https://androidmacro.com/docs/logic/comparison.md) - [Logic Operations](https://androidmacro.com/docs/logic/operations.md) - [Ternary Logic](https://androidmacro.com/docs/logic/ternary.md) ## Boolean Logic Canonical URL: https://androidmacro.com/docs/logic/boolean Markdown URL: https://androidmacro.com/docs/logic/boolean.md # Boolean Logic Canonical URL: https://androidmacro.com/docs/logic/boolean Source file: /docs/logic/boolean.md --- Boolean logic deals with true and false values. These are the fundamental building blocks for making decisions in your macros. ## Boolean Values The simplest logic blocks represent the values `true` and `false`. > Interactive Blockly example omitted in Markdown export. - **True**: Represents a condition that is met or correct. - **False**: Represents a condition that is not met or incorrect. ## Null The `null` block represents a lack of value. It is rarely used in simple macros but can be useful for advanced logic or initializing variables to "nothing". > Interactive Blockly example omitted in Markdown export. ## Usage You often use these blocks to: - Set flags or variables (e.g., `set is_running to true`). - Pass as parameters to functions that expect a yes/no answer. - Create infinite loops (e.g., `repeat while true`). ## Logic Comparisons Canonical URL: https://androidmacro.com/docs/logic/comparison Markdown URL: https://androidmacro.com/docs/logic/comparison.md # Logic Comparisons Canonical URL: https://androidmacro.com/docs/logic/comparison Source file: /docs/logic/comparison.md --- Comparison blocks allow you to compare two values to determine how they relate to each other. These are essential for creating conditions. ## Compare Numbers or Text The main comparison block can check for equality or inequality. > Interactive Blockly example omitted in Markdown export. ### Available Operators - **= (Equal)**: Checks if two values are exactly the same. - `5 = 5` is true. - `apple = orange` is false. - **≠ (Not Equal)**: Checks if two values are different. - ** (Greater Than)**: Checks if the first value is larger. - **≥ (Greater Than or Equal)** ## Example Checking if a variable `score` is greater than 100: > Interactive Blockly example omitted in Markdown export. ## Logic Operations Canonical URL: https://androidmacro.com/docs/logic/operations Markdown URL: https://androidmacro.com/docs/logic/operations.md # Logic Operations Canonical URL: https://androidmacro.com/docs/logic/operations Source file: /docs/logic/operations.md --- Logic operations allow you to combine multiple conditions to create more complex decision-making rules. ## And / Or The `and` / `or` block combines two boolean values. > Interactive Blockly example omitted in Markdown export. - **AND**: Returns true only if **both** inputs are true. - Example: `Image A found` **AND** `Image B found`. - **OR**: Returns true if **at least one** of the inputs is true. - Example: `Image A found` **OR** `Image B found`. ## Not The `not` block inverts a boolean value. > Interactive Blockly example omitted in Markdown export. - Returns `true` if the input is `false`. - Returns `false` if the input is `true`. - **Usage**: "Repeat while **not** image found" (Wait until image appears). ## Example Checking if we should click a button only if the screen is ready AND the button is visible: > Interactive Blockly example omitted in Markdown export. ## Ternary Logic Canonical URL: https://androidmacro.com/docs/logic/ternary Markdown URL: https://androidmacro.com/docs/logic/ternary.md # Ternary Logic Canonical URL: https://androidmacro.com/docs/logic/ternary Source file: /docs/logic/ternary.md --- # Ternary Logic (If-Return) The **Ternary** block is a compact way to make a decision and return a value based on that decision. It works like an inline `if-else` statement. ## Test - Use If True - Use If False > Interactive Blockly example omitted in Markdown export. This block takes three inputs: 1. **if**: A condition to test (must return true/false). 2. **then**: The value to return if the condition is **true**. 3. **else**: The value to return if the condition is **false**. ## Example Setting a variable `status_text` based on a boolean `is_ready`: - If `is_ready` is true, set `status_text` to "Ready!". - If `is_ready` is false, set `status_text` to "Loading...". ## Loop & Repeat Canonical URL: https://androidmacro.com/docs/loop Markdown URL: https://androidmacro.com/docs/loop.md # Loop & Repeat Canonical URL: https://androidmacro.com/docs/loop Source file: /docs/loop/_category_.json --- Learn repeatable or loop concept for automation in Android Macro ## Pages - [Examples](https://androidmacro.com/docs/loop/example.md) - [Repeat & Loops](https://androidmacro.com/docs/loop/repeat-loop.md) ## Examples Canonical URL: https://androidmacro.com/docs/loop/example Markdown URL: https://androidmacro.com/docs/loop/example.md # Examples Canonical URL: https://androidmacro.com/docs/loop/example Source file: /docs/loop/example.md --- How to Use Loops in Android Macro ### Repeat & Loop Example Here's how you can use the repeat & loop in Android Macro: > Interactive Blockly example omitted in Markdown export. #### What This Example Does: This example demonstrates a basic loop structure that: 1. Repeats an action 10 times 2. Waits for a specific image to appear 3. Clicks on that image #### Breaking It Down: - The outer green block is the `repeat` block. It's set to run `10 times`. - Inside the repeat block, there are two actions: 1. `wait image`: This block waits for "your-image.jpg" to appear on the screen. It will wait for up to 5000 milliseconds (5 seconds). 2. `click image`: Once the image appears (or after 5 seconds), this block clicks on "your-image.jpg". #### Practical Uses: This sequence will repeat 10 times. It's useful for tasks like: - Repeatedly checking for and clicking on a button that appears periodically - Automating a process that needs to be done multiple times #### How to Use This Example: To use this in your own macro: 1. Drag the `repeat` block from the `Loops` section on the left. 2. Set the number of repetitions (in this case, 10). 3. Add the `wait image` and `click image` blocks inside the repeat block. 4. Customize the image name and wait time as needed. **Note:** Remember to replace "your-image.jpg" with the actual image you want to interact with in your macro. This simple example shows how you can easily create powerful, repetitive tasks in Android Macro without needing to write complex code. ## Repeat & Loops Canonical URL: https://androidmacro.com/docs/loop/repeat-loop Markdown URL: https://androidmacro.com/docs/loop/repeat-loop.md # Repeat & Loops Canonical URL: https://androidmacro.com/docs/loop/repeat-loop Source file: /docs/loop/repeat-loop.md --- ## What is Looping? In Android Macro, looping is the process of executing a block of code multiple times. It's a fundamental concept that allows programs to perform repetitive tasks efficiently without having to write the same code over and over again. In Android Macro, loops are visual blocks that let you repeat actions for a certain number of times or until a specific condition is met. ### Types of Loops in Android Macro Android Macro provides different types of loops to handle various scenarios: 1. **Repeat Loop**: This loop repeats the set of actions a specific number of times. It's useful when you know exactly how many times you want the loop to run. 2. **While Loop**: This loop continues to repeat the actions as long as a certain condition is true. It's useful when you want the loop to run until something changes in your program. 3. **For Loop**: This loop runs a block of code a set number of times, often using a counter that increases or decreases with each iteration. It's similar to the repeat loop but offers more control over the starting point, end point, and step size. 4. **Do While Loop**: Similar to the while loop, but the condition is checked after the code block has been executed. This ensures that the code block is executed at least once. ## Math Canonical URL: https://androidmacro.com/docs/math Markdown URL: https://androidmacro.com/docs/math.md # Math Canonical URL: https://androidmacro.com/docs/math Source file: /docs/math/_category_.json --- Advanced mathematical operations and constants. ## Pages - [Advanced Math](https://androidmacro.com/docs/math/advanced.md) - [Number Checks](https://androidmacro.com/docs/math/checks.md) - [Constants](https://androidmacro.com/docs/math/constants.md) - [Math on Lists](https://androidmacro.com/docs/math/list-operations.md) - [Random Numbers](https://androidmacro.com/docs/math/random.md) - [Rounding](https://androidmacro.com/docs/math/rounding.md) - [Trigonometry](https://androidmacro.com/docs/math/trigonometry.md) ## Advanced Math Canonical URL: https://androidmacro.com/docs/math/advanced Markdown URL: https://androidmacro.com/docs/math/advanced.md # Advanced Math Canonical URL: https://androidmacro.com/docs/math/advanced Source file: /docs/math/advanced.md --- ## Modulo (Remainder) Returns the remainder after dividing one number by another. > Interactive Blockly example omitted in Markdown export. **Example**: `64 modulo 10` returns `4`. ## Constrain Forces a number to be within a specific range. > Interactive Blockly example omitted in Markdown export. - If the number is lower than `low`, it returns `low`. - If the number is higher than `high`, it returns `high`. - Otherwise, it returns the number itself. ## Number Checks Canonical URL: https://androidmacro.com/docs/math/checks Markdown URL: https://androidmacro.com/docs/math/checks.md # Number Checks Canonical URL: https://androidmacro.com/docs/math/checks Source file: /docs/math/checks.md --- Check if a number has specific properties. These blocks return `true` or `false`. ## Property Check Block > Interactive Blockly example omitted in Markdown export. ### Properties - **Even**: Divisible by 2. - **Odd**: Not divisible by 2. - **Prime**: Divisible only by 1 and itself. - **Whole**: No decimal part. - **Positive**: Greater than 0. - **Negative**: Less than 0. - **Divisible by**: Checks if the number is divisible by a specific value. ## Example Check if a number is even: > Interactive Blockly example omitted in Markdown export. ## Constants Canonical URL: https://androidmacro.com/docs/math/constants Markdown URL: https://androidmacro.com/docs/math/constants.md # Constants Canonical URL: https://androidmacro.com/docs/math/constants Source file: /docs/math/constants.md --- # Math Constants Access common mathematical constants for your calculations. ## Constant Block > Interactive Blockly example omitted in Markdown export. The dropdown provides access to: - **π (Pi)**: ~3.14159 - **e**: ~2.71828 - **φ (Golden Ratio)**: ~1.61803 - **sqrt(2)**: Square root of 2 (~1.414) - **sqrt(½)**: Square root of 0.5 (~0.707) - **∞ (Infinity)**: Represents an infinitely large number. ## Math on Lists Canonical URL: https://androidmacro.com/docs/math/list-operations Markdown URL: https://androidmacro.com/docs/math/list-operations.md # Math on Lists Canonical URL: https://androidmacro.com/docs/math/list-operations Source file: /docs/math/list-operations.md --- Perform calculations on a list of numbers. ## List Operation Block > Interactive Blockly example omitted in Markdown export. ### Operations - **Sum**: Adds all numbers in the list. - **Min**: Finds the smallest number. - **Max**: Finds the largest number. - **Average**: Calculates the arithmetic mean. - **Median**: Finds the median value. - **Modes**: Finds the most common value(s) (returns a list). - **Standard Deviation**: Calculates standard deviation. - **Random Item**: Returns a random item from the list. ## Random Numbers Canonical URL: https://androidmacro.com/docs/math/random Markdown URL: https://androidmacro.com/docs/math/random.md # Random Numbers Canonical URL: https://androidmacro.com/docs/math/random Source file: /docs/math/random.md --- Generate random values for varied behavior in macros. ## Random Integer Generates a random whole number between two limits (inclusive). > Interactive Blockly example omitted in Markdown export. **Example**: Random wait time between 1 and 5 seconds. ## Random Fraction Returns a random decimal number between 0.0 (inclusive) and 1.0 (exclusive). > Interactive Blockly example omitted in Markdown export. **Usage**: Useful for probability checks (e.g., "If random fraction 30% chance). ## Rounding Canonical URL: https://androidmacro.com/docs/math/rounding Markdown URL: https://androidmacro.com/docs/math/rounding.md # Rounding Canonical URL: https://androidmacro.com/docs/math/rounding Source file: /docs/math/rounding.md --- Round decimal values to integers. ## Round Block > Interactive Blockly example omitted in Markdown export. ### Options - **Round**: Standard rounding (nearest integer). 3.5 becomes 4, 3.4 becomes 3. - **Round Up (Ceiling)**: Always rounds up to the next integer. 3.1 becomes 4. - **Round Down (Floor)**: Always rounds down. 3.9 becomes 3. ## Trigonometry Canonical URL: https://androidmacro.com/docs/math/trigonometry Markdown URL: https://androidmacro.com/docs/math/trigonometry.md # Trigonometry Canonical URL: https://androidmacro.com/docs/math/trigonometry Source file: /docs/math/trigonometry.md --- # Trigonometry & Functions Perform advanced mathematical functions on numbers. ## Trig/Func Block > Interactive Blockly example omitted in Markdown export. ### Operations - **Square Root (sqrt)** - **Absolute Value (abs)**: Returns the non-negative value. - **-**: Negates the number (e.g., 5 to -5). - **ln**: Natural logarithm. - **log10**: Logarithm base 10. - **e^**: Exponential function. - **10^**: Power of 10. - **sin, cos, tan**: Standard trigonometric functions (in degrees). - **asin, acos, atan**: Inverse trigonometric functions. ## Usage Note Trigonometric functions in Blockly typically expect or return **degrees**. ## Native Service Canonical URL: https://androidmacro.com/docs/native-service Markdown URL: https://androidmacro.com/docs/native-service.md # Native Service Canonical URL: https://androidmacro.com/docs/native-service Source file: /docs/native-service.md --- The Native Service provides an alternative solution for ROOTED devices to perform actions like clicks, swipes, and more. This feature is especially useful for older devices that lack the Accessibility Service, ensuring compatibility with Android Macro. To enable this service, we developed a third-party app called "Android Macro Activator." ## How to Enable Native Service Follow these steps to enable the Native Service on your rooted device: 1. Please ensure that you have ROOTED devices 2. Download Android Macro Activator [Click Here](https://androidmacro.com/apk/androidmacro-activator.apk) 3. Enable ROOT permission, optionally you can also disable root notification for better experience 4. In Notification bar, click "START SERVICE" button to start the service 5. You're done! ## Playground Canonical URL: https://androidmacro.com/docs/playground Markdown URL: https://androidmacro.com/docs/playground.md # Playground Canonical URL: https://androidmacro.com/docs/playground Source file: /docs/playground.md --- Welcome to the Playground! Here, you can experiment with Android Macro, copy & test out your code, and see how it works in real time. Use this space to try to make your macro. > Interactive playground omitted in Markdown export. ## Reference Canonical URL: https://androidmacro.com/docs/reference Markdown URL: https://androidmacro.com/docs/reference.md # Reference Canonical URL: https://androidmacro.com/docs/reference Source file: /docs/reference/_category_.json --- Comprehensive API reference documentation covering all Android Macro functions, methods, and settings for building reliable automation scripts. ## Pages - [CheckBox()](https://androidmacro.com/docs/reference/checkbox/checkbox.md) - [CheckBox():getId()](https://androidmacro.com/docs/reference/checkbox/getid.md) - [CheckBox():getText()](https://androidmacro.com/docs/reference/checkbox/gettext.md) - [CheckBox():getTextSize()](https://androidmacro.com/docs/reference/checkbox/gettextsize.md) - [ClickParams()](https://androidmacro.com/docs/reference/click-params/click-params.md) - [ClickParams():getDelay()](https://androidmacro.com/docs/reference/click-params/getdelay.md) - [ClickParams():getDuration()](https://androidmacro.com/docs/reference/click-params/getduration.md) - [ClickParams():getOffset()](https://androidmacro.com/docs/reference/click-params/getoffset.md) - [ClickParams():setDelay()](https://androidmacro.com/docs/reference/click-params/setdelay.md) - [ClickParams():setDuration()](https://androidmacro.com/docs/reference/click-params/setduration.md) - [ClickParams():setOffset()](https://androidmacro.com/docs/reference/click-params/setoffset.md) - [Clipboard:copy()](https://androidmacro.com/docs/reference/clipboard/copy.md) - [Clipboard:paste()](https://androidmacro.com/docs/reference/clipboard/paste.md) - [Clipboard:read()](https://androidmacro.com/docs/reference/clipboard/read.md) - [Color():blue()](https://androidmacro.com/docs/reference/color/blue.md) - [Color()](https://androidmacro.com/docs/reference/color/color.md) - [Color():compare()](https://androidmacro.com/docs/reference/color/compare.md) - [Color():getHex()](https://androidmacro.com/docs/reference/color/gethex.md) - [Color():green()](https://androidmacro.com/docs/reference/color/green.md) - [Color():isEqual()](https://androidmacro.com/docs/reference/color/isequal.md) - [Color():red()](https://androidmacro.com/docs/reference/color/red.md) - [Column()](https://androidmacro.com/docs/reference/column/column.md) - [Column():getId()](https://androidmacro.com/docs/reference/column/getid.md) - [DateTime():add()](https://androidmacro.com/docs/reference/datetime/add.md) - [DateTime():date()](https://androidmacro.com/docs/reference/datetime/date.md) - [DateTime()](https://androidmacro.com/docs/reference/datetime/datetime.md) - [DateTime():day()](https://androidmacro.com/docs/reference/datetime/day.md) - [DateTime():diff()](https://androidmacro.com/docs/reference/datetime/diff.md) - [DateTime():endOf()](https://androidmacro.com/docs/reference/datetime/endof.md) - [DateTime():format()](https://androidmacro.com/docs/reference/datetime/format.md) - [DateTime():hour()](https://androidmacro.com/docs/reference/datetime/hour.md) - [DateTime():isAfter()](https://androidmacro.com/docs/reference/datetime/isafter.md) - [DateTime():isBefore()](https://androidmacro.com/docs/reference/datetime/isbefore.md) - [DateTime():isBetween()](https://androidmacro.com/docs/reference/datetime/isbetween.md) - [DateTime():isSame()](https://androidmacro.com/docs/reference/datetime/issame.md) - [DateTime():isSameOrAfter()](https://androidmacro.com/docs/reference/datetime/issameorafter.md) - [DateTime():isSameOrBefore()](https://androidmacro.com/docs/reference/datetime/issameorbefore.md) - [DateTime():local()](https://androidmacro.com/docs/reference/datetime/local.md) - [DateTime():millisecond()](https://androidmacro.com/docs/reference/datetime/millisecond.md) - [DateTime():minute()](https://androidmacro.com/docs/reference/datetime/minute.md) - [DateTime():month()](https://androidmacro.com/docs/reference/datetime/month.md) - [DateTime():second()](https://androidmacro.com/docs/reference/datetime/second.md) - [DateTime():date()](https://androidmacro.com/docs/reference/datetime/set-date.md) - [DateTime():hour()](https://androidmacro.com/docs/reference/datetime/set-hour.md) - [DateTime():millisecond()](https://androidmacro.com/docs/reference/datetime/set-millisecond.md) - [DateTime():minute()](https://androidmacro.com/docs/reference/datetime/set-minute.md) - [DateTime():month()](https://androidmacro.com/docs/reference/datetime/set-month.md) - [DateTime():second()](https://androidmacro.com/docs/reference/datetime/set-second.md) - [DateTime():year()](https://androidmacro.com/docs/reference/datetime/set-year.md) - [DateTime():startOf()](https://androidmacro.com/docs/reference/datetime/startof.md) - [DateTime():subtract()](https://androidmacro.com/docs/reference/datetime/subtract.md) - [DateTime():toISOString()](https://androidmacro.com/docs/reference/datetime/toisostring.md) - [DateTime():tz()](https://androidmacro.com/docs/reference/datetime/tz.md) - [DateTime():unix()](https://androidmacro.com/docs/reference/datetime/unix.md) - [DateTime():utc()](https://androidmacro.com/docs/reference/datetime/utc.md) - [DateTime():valueOf()](https://androidmacro.com/docs/reference/datetime/valueof.md) - [DateTime():year()](https://androidmacro.com/docs/reference/datetime/year.md) - [Dialog:add()](https://androidmacro.com/docs/reference/dialog/add.md) - [Dialog:getValueById()](https://androidmacro.com/docs/reference/dialog/getvaluebyid.md) - [Dialog:getValueOf()](https://androidmacro.com/docs/reference/dialog/getvalueof.md) - [Dialog:init()](https://androidmacro.com/docs/reference/dialog/init.md) - [Dialog:remove()](https://androidmacro.com/docs/reference/dialog/remove.md) - [Dialog:setMessage()](https://androidmacro.com/docs/reference/dialog/setmessage.md) - [Dialog:setTitle()](https://androidmacro.com/docs/reference/dialog/settitle.md) - [Dialog:show()](https://androidmacro.com/docs/reference/dialog/show.md) - [EditText()](https://androidmacro.com/docs/reference/edittext/edittext.md) - [EditText():getHint()](https://androidmacro.com/docs/reference/edittext/gethint.md) - [EditText():getHint()](https://androidmacro.com/docs/reference/edittext/gettextcolor.md) - [EditText():getTextSize()](https://androidmacro.com/docs/reference/edittext/gettextsize.md) - [FinderParams()](https://androidmacro.com/docs/reference/finder-params/find-params.md) - [FinderParams():getDelay()](https://androidmacro.com/docs/reference/finder-params/getdelay.md) - [FinderParams():getDetectionEngine()](https://androidmacro.com/docs/reference/finder-params/getdetectionengine.md) - [FinderParams():getDetectionMethod()](https://androidmacro.com/docs/reference/finder-params/getdetectionmethod.md) - [FinderParams():getDetectionType()](https://androidmacro.com/docs/reference/finder-params/getdetectiontype.md) - [FinderParams():getHighlightDuration()](https://androidmacro.com/docs/reference/finder-params/gethighlightduration.md) - [FinderParams():getHighlightTooltip()](https://androidmacro.com/docs/reference/finder-params/gethighlighttooltip.md) - [FinderParams():getScore()](https://androidmacro.com/docs/reference/finder-params/getscore.md) - [FinderParams():isDynamicScaling()](https://androidmacro.com/docs/reference/finder-params/isdynamicscaling.md) - [FinderParams():isGrayscale()](https://androidmacro.com/docs/reference/finder-params/isgrayscale.md) - [FinderParams():isHighlight()](https://androidmacro.com/docs/reference/finder-params/ishighlight.md) - [FinderParams():setDelay()](https://androidmacro.com/docs/reference/finder-params/setdelay.md) - [FinderParams():setDetectionEngine()](https://androidmacro.com/docs/reference/finder-params/setdetectionengine.md) - [FinderParams():setDetectionMethod()](https://androidmacro.com/docs/reference/finder-params/setdetectionmethod.md) - [FinderParams():setDetectionType()](https://androidmacro.com/docs/reference/finder-params/setdetectiontype.md) - [FinderParams():setDynamicScaling()](https://androidmacro.com/docs/reference/finder-params/setdynamicscaling.md) - [FinderParams():setGrayscale()](https://androidmacro.com/docs/reference/finder-params/setgrayscale.md) - [FinderParams():setHighlight()](https://androidmacro.com/docs/reference/finder-params/sethighlight.md) - [FinderParams():setHighlightDuration()](https://androidmacro.com/docs/reference/finder-params/sethighlightduration.md) - [FinderParams():setHighlightTooltip()](https://androidmacro.com/docs/reference/finder-params/sethighlighttooltip.md) - [FinderParams():setScore()](https://androidmacro.com/docs/reference/finder-params/setscore.md) - [Keyboard](https://androidmacro.com/docs/reference/keyboard/keyboard.md) - [Keyboard:type()](https://androidmacro.com/docs/reference/keyboard/type.md) - [Macro():executeBlock()](https://androidmacro.com/docs/reference/macro/executeblock.md) - [Macro():executeCode()](https://androidmacro.com/docs/reference/macro/executecode.md) - [Macro():getBlock()](https://androidmacro.com/docs/reference/macro/getblock.md) - [Macro():getCode()](https://androidmacro.com/docs/reference/macro/getcode.md) - [Macro():getId()](https://androidmacro.com/docs/reference/macro/getid.md) - [Macro:getList()](https://androidmacro.com/docs/reference/macro/getlist.md) - [Macro():getName()](https://androidmacro.com/docs/reference/macro/getname.md) - [Macro()](https://androidmacro.com/docs/reference/macro/macro.md) - [MatchResult:getMiddleX()](https://androidmacro.com/docs/reference/match-result/getmiddlex.md) - [MatchResult:getMiddleY()](https://androidmacro.com/docs/reference/match-result/getmiddley.md) - [MatchResult:getPoint()](https://androidmacro.com/docs/reference/match-result/getpoint.md) - [MatchResult:getRegion()](https://androidmacro.com/docs/reference/match-result/getregion.md) - [MatchResult:getScore()](https://androidmacro.com/docs/reference/match-result/getscore.md) - [MatchResult:getText()](https://androidmacro.com/docs/reference/match-result/gettext.md) - [MatchResult:getX()](https://androidmacro.com/docs/reference/match-result/getx.md) - [MatchResult:getY()](https://androidmacro.com/docs/reference/match-result/gety.md) - [Point():getX()](https://androidmacro.com/docs/reference/point/getx.md) - [Point():getY()](https://androidmacro.com/docs/reference/point/gety.md) - [Point()](https://androidmacro.com/docs/reference/point/point.md) - [Point():setX()](https://androidmacro.com/docs/reference/point/setx.md) - [Point():setY()](https://androidmacro.com/docs/reference/point/sety.md) - [RadioButton():getId()](https://androidmacro.com/docs/reference/radio-button/getid.md) - [RadioButton():getText()](https://androidmacro.com/docs/reference/radio-button/gettext.md) - [RadioButton()](https://androidmacro.com/docs/reference/radio-button/radio-button.md) - [RadioGroup():add()](https://androidmacro.com/docs/reference/radio-group/add.md) - [RadioGroup():getButtons()](https://androidmacro.com/docs/reference/radio-group/getbuttons.md) - [RadioGroup():getId()](https://androidmacro.com/docs/reference/radio-group/getid.md) - [RadioGroup()](https://androidmacro.com/docs/reference/radio-group/radio-group.md) - [Record:play()](https://androidmacro.com/docs/reference/record/play.md) - [Record](https://androidmacro.com/docs/reference/record/record.md) - [Region():click()](https://androidmacro.com/docs/reference/region/click.md) - [Region():clickAll()](https://androidmacro.com/docs/reference/region/clickall.md) - [Region():exist()](https://androidmacro.com/docs/reference/region/exist.md) - [Region():existClick()](https://androidmacro.com/docs/reference/region/existclick.md) - [Region():existClickAll()](https://androidmacro.com/docs/reference/region/existclickall.md) - [Region():find()](https://androidmacro.com/docs/reference/region/find.md) - [Region():findAll()](https://androidmacro.com/docs/reference/region/findall.md) - [Region():getColor()](https://androidmacro.com/docs/reference/region/getcolor.md) - [Region():getColors()](https://androidmacro.com/docs/reference/region/getcolors.md) - [Region():getText()](https://androidmacro.com/docs/reference/region/gettext.md) - [Region():getTextMatches()](https://androidmacro.com/docs/reference/region/gettextmatches.md) - [Region():getX()](https://androidmacro.com/docs/reference/region/getx.md) - [Region():getY()](https://androidmacro.com/docs/reference/region/gety.md) - [Region():height()](https://androidmacro.com/docs/reference/region/height.md) - [Region():highlight()](https://androidmacro.com/docs/reference/region/highlight.md) - [Region():multiSwipe()](https://androidmacro.com/docs/reference/region/multiswipe.md) - [Region()](https://androidmacro.com/docs/reference/region/region.md) - [Region():screenshot()](https://androidmacro.com/docs/reference/region/screenshot.md) - [Region():swipe()](https://androidmacro.com/docs/reference/region/swipe.md) - [Region():wait()](https://androidmacro.com/docs/reference/region/wait.md) - [Region():waitClick()](https://androidmacro.com/docs/reference/region/waitclick.md) - [Region():waitVanish()](https://androidmacro.com/docs/reference/region/waitvanish.md) - [Region():width()](https://androidmacro.com/docs/reference/region/width.md) - [Request():delete()](https://androidmacro.com/docs/reference/request/delete.md) - [Request():get()](https://androidmacro.com/docs/reference/request/get.md) - [Request():patch()](https://androidmacro.com/docs/reference/request/patch.md) - [Request():post()](https://androidmacro.com/docs/reference/request/post.md) - [Request():put()](https://androidmacro.com/docs/reference/request/put.md) - [Request()](https://androidmacro.com/docs/reference/request/request.md) - [Request():setHeader()](https://androidmacro.com/docs/reference/request/setheader.md) - [Request():setParameter()](https://androidmacro.com/docs/reference/request/setparameter.md) - [Response:getData()](https://androidmacro.com/docs/reference/response/getdata.md) - [Response:getResponseCode()](https://androidmacro.com/docs/reference/response/getresponsecode.md) - [Response](https://androidmacro.com/docs/reference/response/response.md) - [Row():getId()](https://androidmacro.com/docs/reference/row/getid.md) - [Row()](https://androidmacro.com/docs/reference/row/row.md) - [Screen:click()](https://androidmacro.com/docs/reference/screen/click.md) - [Screen:clickAll()](https://androidmacro.com/docs/reference/screen/clickall.md) - [Screen](https://androidmacro.com/docs/reference/screen/constructor.md) - [Screen:exist()](https://androidmacro.com/docs/reference/screen/exist.md) - [Screen:existClick()](https://androidmacro.com/docs/reference/screen/existclick.md) - [Screen:existClickAll()](https://androidmacro.com/docs/reference/screen/existclickall.md) - [Screen:find()](https://androidmacro.com/docs/reference/screen/find.md) - [Screen:findAll()](https://androidmacro.com/docs/reference/screen/findall.md) - [Screen:getColor()](https://androidmacro.com/docs/reference/screen/getcolor.md) - [Screen:getColors()](https://androidmacro.com/docs/reference/screen/getcolors.md) - [Screen:getText()](https://androidmacro.com/docs/reference/screen/gettext.md) - [Screen():getTextMatches()](https://androidmacro.com/docs/reference/screen/gettextmatches.md) - [Screen:getX()](https://androidmacro.com/docs/reference/screen/getx.md) - [Screen:getY()](https://androidmacro.com/docs/reference/screen/gety.md) - [Screen:height()](https://androidmacro.com/docs/reference/screen/height.md) - [Screen:highlight()](https://androidmacro.com/docs/reference/screen/highlight.md) - [Screen:multiSwipe()](https://androidmacro.com/docs/reference/screen/multiswipe.md) - [Screen:screenshot()](https://androidmacro.com/docs/reference/screen/screenshot.md) - [Screen:swipe()](https://androidmacro.com/docs/reference/screen/swipe.md) - [Screen:wait()](https://androidmacro.com/docs/reference/screen/wait.md) - [Screen():waitClick()](https://androidmacro.com/docs/reference/screen/waitclick.md) - [Screen:waitVanish()](https://androidmacro.com/docs/reference/screen/waitvanish.md) - [Screen:width()](https://androidmacro.com/docs/reference/screen/width.md) - [Settings:cacheOff()](https://androidmacro.com/docs/reference/settings/cacheoff.md) - [Settings:cacheOn()](https://androidmacro.com/docs/reference/settings/cacheon.md) - [Settings:getClickDelay()](https://androidmacro.com/docs/reference/settings/getclickdelay.md) - [Settings:getImagePath()](https://androidmacro.com/docs/reference/settings/getimagepath.md) - [Settings:getMinScore()](https://androidmacro.com/docs/reference/settings/getminscore.md) - [Settings:getScanInterval()](https://androidmacro.com/docs/reference/settings/getscaninterval.md) - [Settings:getSwipeDelay()](https://androidmacro.com/docs/reference/settings/getswipedelay.md) - [Settings:grayscaleOff()](https://androidmacro.com/docs/reference/settings/grayscaleoff.md) - [Settings:grayscaleOn()](https://androidmacro.com/docs/reference/settings/grayscaleon.md) - [Settings:isGrayscale()](https://androidmacro.com/docs/reference/settings/isgrayscale.md) - [Settings:setClickDelay()](https://androidmacro.com/docs/reference/settings/setclickdelay.md) - [Settings:setComparisonHeight()](https://androidmacro.com/docs/reference/settings/setcomparisonheight.md) - [Settings:setComparisonWidth()](https://androidmacro.com/docs/reference/settings/setcomparisonwidth.md) - [Settings:setMinScore()](https://androidmacro.com/docs/reference/settings/setminscore.md) - [Settings:setScanInterval()](https://androidmacro.com/docs/reference/settings/setscaninterval.md) - [Settings:setSwipeDelay()](https://androidmacro.com/docs/reference/settings/setswipedelay.md) - [Settings](https://androidmacro.com/docs/reference/settings/settings.md) - [Storage:append()](https://androidmacro.com/docs/reference/storage/append.md) - [Storage:delete()](https://androidmacro.com/docs/reference/storage/delete.md) - [Storage:read()](https://androidmacro.com/docs/reference/storage/read.md) - [Storage:write()](https://androidmacro.com/docs/reference/storage/write.md) - [SwipeParams():getDelay()](https://androidmacro.com/docs/reference/swipe-params/getdelay.md) - [SwipeParams():isContinue()](https://androidmacro.com/docs/reference/swipe-params/iscontinue.md) - [SwipeParams():setContinue()](https://androidmacro.com/docs/reference/swipe-params/setcontinue.md) - [SwipeParams():setDelay()](https://androidmacro.com/docs/reference/swipe-params/setdelay.md) - [SwipeParams()](https://androidmacro.com/docs/reference/swipe-params/swipe-params.md) - [SwipePoint():getHoldDuration()](https://androidmacro.com/docs/reference/swipepoint/getholdduration.md) - [SwipePoint():getSpeed() [DEPRECATED]](https://androidmacro.com/docs/reference/swipepoint/getspeed.md) - [SwipePoint():getSwipeDuration()](https://androidmacro.com/docs/reference/swipepoint/getswipeduration.md) - [SwipePoint():getX()](https://androidmacro.com/docs/reference/swipepoint/getx.md) - [SwipePoint():getY()](https://androidmacro.com/docs/reference/swipepoint/gety.md) - [SwipePoint():setHoldDuration()](https://androidmacro.com/docs/reference/swipepoint/setholdduration.md) - [SwipePoint():setSpeed() [DEPRECATED]](https://androidmacro.com/docs/reference/swipepoint/setspeed.md) - [SwipePoint():setSwipeDuration()](https://androidmacro.com/docs/reference/swipepoint/setswipeduration.md) - [SwipePoint():setX()](https://androidmacro.com/docs/reference/swipepoint/setx.md) - [SwipePoint():setY()](https://androidmacro.com/docs/reference/swipepoint/sety.md) - [SwipePoint()](https://androidmacro.com/docs/reference/swipepoint/swipepoint.md) - [System:back()](https://androidmacro.com/docs/reference/system/back.md) - [System:home()](https://androidmacro.com/docs/reference/system/home.md) - [System:recent()](https://androidmacro.com/docs/reference/system/recent.md) - [System:spawn()](https://androidmacro.com/docs/reference/system/spawn.md) - [System](https://androidmacro.com/docs/reference/system/system.md) - [TextView():getText()](https://androidmacro.com/docs/reference/textview/gettext.md) - [TextView()](https://androidmacro.com/docs/reference/textview/textview.md) - [ToastParams():getDuration()](https://androidmacro.com/docs/reference/toast-params/getduration.md) - [ToastParams():getOpacity()](https://androidmacro.com/docs/reference/toast-params/getopacity.md) - [ToastParams():getPadding()](https://androidmacro.com/docs/reference/toast-params/getpadding.md) - [ToastParams():getPosition()](https://androidmacro.com/docs/reference/toast-params/getposition.md) - [ToastParams():getRadius()](https://androidmacro.com/docs/reference/toast-params/getradius.md) - [ToastParams():getTextColor()](https://androidmacro.com/docs/reference/toast-params/gettextcolor.md) - [ToastParams():setDuration()](https://androidmacro.com/docs/reference/toast-params/setduration.md) - [ToastParams():setOpacity()](https://androidmacro.com/docs/reference/toast-params/setopacity.md) - [ToastParams():setPadding()](https://androidmacro.com/docs/reference/toast-params/setpadding.md) - [ToastParams():setPosition()](https://androidmacro.com/docs/reference/toast-params/setposition.md) - [ToastParams():setRadius()](https://androidmacro.com/docs/reference/toast-params/setradius.md) - [ToastParams():setTextColor()](https://androidmacro.com/docs/reference/toast-params/settextcolor.md) - [ToastParams()](https://androidmacro.com/docs/reference/toast-params/toast-params.md) - [Toolbar:getOpacity()](https://androidmacro.com/docs/reference/toolbar/getopacity.md) - [Toolbar:getScale()](https://androidmacro.com/docs/reference/toolbar/getscale.md) - [Toolbar:hide()](https://androidmacro.com/docs/reference/toolbar/hide.md) - [Toolbar:isAvailable()](https://androidmacro.com/docs/reference/toolbar/isavailable.md) - [Toolbar:isSnapped()](https://androidmacro.com/docs/reference/toolbar/issnapped.md) - [Toolbar:isVisible()](https://androidmacro.com/docs/reference/toolbar/isvisible.md) - [Toolbar:setCollapse()](https://androidmacro.com/docs/reference/toolbar/setcollapse.md) - [Toolbar:setOpacity()](https://androidmacro.com/docs/reference/toolbar/setopacity.md) - [Toolbar:setPosition()](https://androidmacro.com/docs/reference/toolbar/setposition.md) - [Toolbar:setScale()](https://androidmacro.com/docs/reference/toolbar/setscale.md) - [Toolbar:setSnap()](https://androidmacro.com/docs/reference/toolbar/setsnap.md) - [Toolbar:show()](https://androidmacro.com/docs/reference/toolbar/show.md) - [Toolbar](https://androidmacro.com/docs/reference/toolbar/toolbar.md) - [Touch:dispatch()](https://androidmacro.com/docs/reference/touch/dispatch.md) - [Touch:down()](https://androidmacro.com/docs/reference/touch/down.md) - [Touch:exit()](https://androidmacro.com/docs/reference/touch/exit.md) - [Touch:init()](https://androidmacro.com/docs/reference/touch/init.md) - [Touch:move()](https://androidmacro.com/docs/reference/touch/move.md) - [Touch](https://androidmacro.com/docs/reference/touch/touch.md) - [Touch:up()](https://androidmacro.com/docs/reference/touch/up.md) - [Utils:alert()](https://androidmacro.com/docs/reference/utils/alert.md) - [Utils:interpolatePoints()](https://androidmacro.com/docs/reference/utils/interpolatepoints.md) - [Utils:sleep()](https://androidmacro.com/docs/reference/utils/sleep.md) - [Utils:toast()](https://androidmacro.com/docs/reference/utils/toast.md) - [Utils](https://androidmacro.com/docs/reference/utils/utils.md) ## CheckBox Canonical URL: https://androidmacro.com/docs/reference/checkbox Markdown URL: https://androidmacro.com/docs/reference/checkbox.md # CheckBox Canonical URL: https://androidmacro.com/docs/reference/checkbox Source file: /docs/reference/checkbox/_category_.json --- Learn the most important android macro concepts. ## Pages - [CheckBox()](https://androidmacro.com/docs/reference/checkbox/checkbox.md) - [CheckBox():getId()](https://androidmacro.com/docs/reference/checkbox/getid.md) - [CheckBox():getText()](https://androidmacro.com/docs/reference/checkbox/gettext.md) - [CheckBox():getTextSize()](https://androidmacro.com/docs/reference/checkbox/gettextsize.md) ## CheckBox() Canonical URL: https://androidmacro.com/docs/reference/checkbox/checkbox Markdown URL: https://androidmacro.com/docs/reference/checkbox/checkbox.md # CheckBox() Canonical URL: https://androidmacro.com/docs/reference/checkbox/checkbox Source file: /docs/reference/checkbox/checkbox.md --- Add checkbox to dialog view ## Constructor ```js CheckBox(id: number, text: string) ``` ```js CheckBox(id: number, text: string, defaultChecked: boolean) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------------------------------------------------------------------- | | id | number | Unique identifier of the checkbox, the id is used in `Dialog:getValueById()` | | text | string | Custom text next to the checkbox | | defaultChecked | boolean | Optional initial checked state | ## Notes - The third parameter is optional - Set `defaultChecked` to `true` if you want the checkbox selected by default - When a default value is provided, it takes priority over previously saved dialog state ## CheckBox():getId() Canonical URL: https://androidmacro.com/docs/reference/checkbox/getid Markdown URL: https://androidmacro.com/docs/reference/checkbox/getid.md # CheckBox():getId() Canonical URL: https://androidmacro.com/docs/reference/checkbox/getid Source file: /docs/reference/checkbox/getid.md --- Will return the current checkbox view id #### Signature ```js getId(): number ``` **Returns** `number` ## CheckBox():getText() Canonical URL: https://androidmacro.com/docs/reference/checkbox/gettext Markdown URL: https://androidmacro.com/docs/reference/checkbox/gettext.md # CheckBox():getText() Canonical URL: https://androidmacro.com/docs/reference/checkbox/gettext Source file: /docs/reference/checkbox/gettext.md --- Will return the current checkbox text #### Signature ```js getText(): string ``` **Returns** `string` ## CheckBox():getTextSize() Canonical URL: https://androidmacro.com/docs/reference/checkbox/gettextsize Markdown URL: https://androidmacro.com/docs/reference/checkbox/gettextsize.md # CheckBox():getTextSize() Canonical URL: https://androidmacro.com/docs/reference/checkbox/gettextsize Source file: /docs/reference/checkbox/gettextsize.md --- Will return the current checkbox text size #### Signature ```js getTextSize(): number ``` **Returns** `number` ## ClickParams Canonical URL: https://androidmacro.com/docs/reference/click-params Markdown URL: https://androidmacro.com/docs/reference/click-params.md # ClickParams Canonical URL: https://androidmacro.com/docs/reference/click-params Source file: /docs/reference/click-params/_category_.json --- Learn the most important android macro concepts. ## Pages - [ClickParams()](https://androidmacro.com/docs/reference/click-params/click-params.md) - [ClickParams():getDelay()](https://androidmacro.com/docs/reference/click-params/getdelay.md) - [ClickParams():getDuration()](https://androidmacro.com/docs/reference/click-params/getduration.md) - [ClickParams():getOffset()](https://androidmacro.com/docs/reference/click-params/getoffset.md) - [ClickParams():setDelay()](https://androidmacro.com/docs/reference/click-params/setdelay.md) - [ClickParams():setDuration()](https://androidmacro.com/docs/reference/click-params/setduration.md) - [ClickParams():setOffset()](https://androidmacro.com/docs/reference/click-params/setoffset.md) ## ClickParams() Canonical URL: https://androidmacro.com/docs/reference/click-params/click-params Markdown URL: https://androidmacro.com/docs/reference/click-params/click-params.md # ClickParams() Canonical URL: https://androidmacro.com/docs/reference/click-params/click-params Source file: /docs/reference/click-params/click-params.md --- Useful to parameterize click event ## Constructor ``` ClickParams() ``` This class will initialize default parameter for click events ## ClickParams():getDelay() Canonical URL: https://androidmacro.com/docs/reference/click-params/getdelay Markdown URL: https://androidmacro.com/docs/reference/click-params/getdelay.md # ClickParams():getDelay() Canonical URL: https://androidmacro.com/docs/reference/click-params/getdelay Source file: /docs/reference/click-params/getdelay.md --- Will return the delay of click #### Signature ```js getDelay(): number ``` **Returns** `number` ## ClickParams():getDuration() Canonical URL: https://androidmacro.com/docs/reference/click-params/getduration Markdown URL: https://androidmacro.com/docs/reference/click-params/getduration.md # ClickParams():getDuration() Canonical URL: https://androidmacro.com/docs/reference/click-params/getduration Source file: /docs/reference/click-params/getduration.md --- This method return the number of click duration in milliseconds #### Signature ```js getDuration(): number ``` **Returns** `number` ## ClickParams():getOffset() Canonical URL: https://androidmacro.com/docs/reference/click-params/getoffset Markdown URL: https://androidmacro.com/docs/reference/click-params/getoffset.md # ClickParams():getOffset() Canonical URL: https://androidmacro.com/docs/reference/click-params/getoffset Source file: /docs/reference/click-params/getoffset.md --- Will return the offset of click representing in `Point` #### Signature ```js getOffset(): Point ``` **Returns** `Point` ## ClickParams():setDelay() Canonical URL: https://androidmacro.com/docs/reference/click-params/setdelay Markdown URL: https://androidmacro.com/docs/reference/click-params/setdelay.md # ClickParams():setDelay() Canonical URL: https://androidmacro.com/docs/reference/click-params/setdelay Source file: /docs/reference/click-params/setdelay.md --- You can set delay in milliseconds of click using this method #### Signature ```js setDelay(): ClickParams ``` **Returns** `ClickParams` ## ClickParams():setDuration() Canonical URL: https://androidmacro.com/docs/reference/click-params/setduration Markdown URL: https://androidmacro.com/docs/reference/click-params/setduration.md # ClickParams():setDuration() Canonical URL: https://androidmacro.com/docs/reference/click-params/setduration Source file: /docs/reference/click-params/setduration.md --- This method is used to set hold long the click lasts in miliseconds #### Signature ```js setDuration(): ClickParams ``` **Returns** `ClickParams` ## ClickParams():setOffset() Canonical URL: https://androidmacro.com/docs/reference/click-params/setoffset Markdown URL: https://androidmacro.com/docs/reference/click-params/setoffset.md # ClickParams():setOffset() Canonical URL: https://androidmacro.com/docs/reference/click-params/setoffset Source file: /docs/reference/click-params/setoffset.md --- When match or coordinate is set, the position of click will be offset based on x and y coordinate #### Signature ```js setOffset(point: Point): ClickParams ``` ```js setOffset(x: number, y: number): ClickParams ``` **Returns** `ClickParams` ## Clipboard Canonical URL: https://androidmacro.com/docs/reference/clipboard Markdown URL: https://androidmacro.com/docs/reference/clipboard.md # Clipboard Canonical URL: https://androidmacro.com/docs/reference/clipboard Source file: /docs/reference/clipboard/_category_.json --- Clipboard methods for copying, reading, and pasting text in Lua macros. ## Pages - [Clipboard:copy()](https://androidmacro.com/docs/reference/clipboard/copy.md) - [Clipboard:paste()](https://androidmacro.com/docs/reference/clipboard/paste.md) - [Clipboard:read()](https://androidmacro.com/docs/reference/clipboard/read.md) ## Clipboard:copy() Canonical URL: https://androidmacro.com/docs/reference/clipboard/copy Markdown URL: https://androidmacro.com/docs/reference/clipboard/copy.md # Clipboard:copy() Canonical URL: https://androidmacro.com/docs/reference/clipboard/copy Source file: /docs/reference/clipboard/copy.md --- Copy a string into the system clipboard. #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------- | | text | string | The text to copy | #### Signature ```js Clipboard:copy(text: string): void ``` **Returns** `void` ## Examples ```js Clipboard:copy("sample.user@example.com") ``` ```js local otp = "482991" Clipboard:copy(otp) ``` ## Notes - The copied value replaces the current clipboard text - After copying, you can use `Clipboard:paste()` to paste it into a focused field ## Clipboard:paste() Canonical URL: https://androidmacro.com/docs/reference/clipboard/paste Markdown URL: https://androidmacro.com/docs/reference/clipboard/paste.md # Clipboard:paste() Canonical URL: https://androidmacro.com/docs/reference/clipboard/paste Source file: /docs/reference/clipboard/paste.md --- Paste the current clipboard text into the focused input field. #### Signature ```js Clipboard:paste(): void ``` **Returns** `void` ## Description This method triggers the Android paste action on the currently focused editable element. ## Examples ```js Clipboard:copy("Hello world") editText(1):click() Clipboard:paste() ``` ```js Clipboard:copy("secret-password") Screen:click(Point(300, 900)) Clipboard:paste() ``` ## Notes - `Clipboard:paste()` requires Accessibility touch mode - The target field must already be focused before calling this method - If there is no focused editable field, the paste action may do nothing ## Clipboard:read() Canonical URL: https://androidmacro.com/docs/reference/clipboard/read Markdown URL: https://androidmacro.com/docs/reference/clipboard/read.md # Clipboard:read() Canonical URL: https://androidmacro.com/docs/reference/clipboard/read Source file: /docs/reference/clipboard/read.md --- Read the current clipboard text. #### Signature ```js Clipboard:read(): string ``` **Returns** `string` - The current clipboard text. Returns an empty string when no text is available. ## Description Use `Clipboard:read()` when your macro needs to inspect what is currently stored in the system clipboard. ## Examples ```js local value = Clipboard:read() print("Clipboard value: " .. value) ``` ```js local copiedText = Clipboard:read() if copiedText == "" then print("Clipboard is empty") end ``` ## Notes - This method reads plain text from the clipboard - If the clipboard has no text, the method returns `""` ## Color Canonical URL: https://androidmacro.com/docs/reference/color Markdown URL: https://androidmacro.com/docs/reference/color.md # Color Canonical URL: https://androidmacro.com/docs/reference/color Source file: /docs/reference/color/_category_.json --- Color functions for generating RGB color values. ## Pages - [Color():blue()](https://androidmacro.com/docs/reference/color/blue.md) - [Color()](https://androidmacro.com/docs/reference/color/color.md) - [Color():compare()](https://androidmacro.com/docs/reference/color/compare.md) - [Color():getHex()](https://androidmacro.com/docs/reference/color/gethex.md) - [Color():green()](https://androidmacro.com/docs/reference/color/green.md) - [Color():isEqual()](https://androidmacro.com/docs/reference/color/isequal.md) - [Color():red()](https://androidmacro.com/docs/reference/color/red.md) ## Color():blue() Canonical URL: https://androidmacro.com/docs/reference/color/blue Markdown URL: https://androidmacro.com/docs/reference/color/blue.md # Color():blue() Canonical URL: https://androidmacro.com/docs/reference/color/blue Source file: /docs/reference/color/blue.md --- Extracts the blue color value from a hex color string. ## Description The `blue()` method extracts the blue channel value from a hex color string. The hex color should be in the format "#RRGGBB" where BB represents the blue component. This method returns the decimal value (0-255) of the blue component. #### Signature ```js blue(): number ``` **Returns** `number` - The blue channel value (0-255) from the hex color ## Color() Canonical URL: https://androidmacro.com/docs/reference/color/color Markdown URL: https://androidmacro.com/docs/reference/color/color.md # Color() Canonical URL: https://androidmacro.com/docs/reference/color/color Source file: /docs/reference/color/color.md --- Utility class to perform color similarity ## Constructor ``` Color(hex: string) ``` #### Parameters | Parameters | Type | Description | | ---------- | -------- | ---------------------------------------------------------- | | hex | `string` | hexadecimal string code representing the color e.g #FFFFFF | ## Color():compare() Canonical URL: https://androidmacro.com/docs/reference/color/compare Markdown URL: https://androidmacro.com/docs/reference/color/compare.md # Color():compare() Canonical URL: https://androidmacro.com/docs/reference/color/compare Source file: /docs/reference/color/compare.md --- Compare both color and get the similarity score #### Signature ```js compare(color: Color): number ``` **Returns** `number` ## Color():getHex() Canonical URL: https://androidmacro.com/docs/reference/color/gethex Markdown URL: https://androidmacro.com/docs/reference/color/gethex.md # Color():getHex() Canonical URL: https://androidmacro.com/docs/reference/color/gethex Source file: /docs/reference/color/gethex.md --- Will return hexadecimal string color #### Signature ```js getHex(): string ``` **Returns** `string` ## Color():green() Canonical URL: https://androidmacro.com/docs/reference/color/green Markdown URL: https://androidmacro.com/docs/reference/color/green.md # Color():green() Canonical URL: https://androidmacro.com/docs/reference/color/green Source file: /docs/reference/color/green.md --- Extracts the green color value from a hex color string. ## Description The `green()` method extracts the green channel value from a hex color string. The hex color should be in the format "#RRGGBB" where GG represents the green component. This method returns the decimal value (0-255) of the green component. #### Signature ```js green(): number ``` **Returns** `number` - The green channel value (0-255) from the hex color ## Color():isEqual() Canonical URL: https://androidmacro.com/docs/reference/color/isequal Markdown URL: https://androidmacro.com/docs/reference/color/isequal.md # Color():isEqual() Canonical URL: https://androidmacro.com/docs/reference/color/isequal Source file: /docs/reference/color/isequal.md --- Check if both color is has similarity to 1 #### Signature ```js isEqual(color: Color): boolean ``` **Returns** `boolean` ## Color():red() Canonical URL: https://androidmacro.com/docs/reference/color/red Markdown URL: https://androidmacro.com/docs/reference/color/red.md # Color():red() Canonical URL: https://androidmacro.com/docs/reference/color/red Source file: /docs/reference/color/red.md --- Extracts the red color value from a hex color string. ## Description The `red()` method extracts the red channel value from a hex color string. The hex color should be in the format "#RRGGBB" where RR represents the red component. This method returns the decimal value (0-255) of the red component. #### Signature ```js red(): number ``` **Returns** `number` - The red channel value (0-255) from the hex color ## Column Canonical URL: https://androidmacro.com/docs/reference/column Markdown URL: https://androidmacro.com/docs/reference/column.md # Column Canonical URL: https://androidmacro.com/docs/reference/column Source file: /docs/reference/column/_category_.json --- Learn the most important android macro concepts. ## Pages - [Column()](https://androidmacro.com/docs/reference/column/column.md) - [Column():getId()](https://androidmacro.com/docs/reference/column/getid.md) ## Column() Canonical URL: https://androidmacro.com/docs/reference/column/column Markdown URL: https://androidmacro.com/docs/reference/column/column.md # Column() Canonical URL: https://androidmacro.com/docs/reference/column/column Source file: /docs/reference/column/column.md --- Add Column view to dialog ## Constructor ``` Column() ``` ## Column():getId() Canonical URL: https://androidmacro.com/docs/reference/column/getid Markdown URL: https://androidmacro.com/docs/reference/column/getid.md # Column():getId() Canonical URL: https://androidmacro.com/docs/reference/column/getid Source file: /docs/reference/column/getid.md --- Will return the id of column view #### Signature ```js getId(): number ``` **Returns** `number` ## DateTime Canonical URL: https://androidmacro.com/docs/reference/datetime Markdown URL: https://androidmacro.com/docs/reference/datetime.md # DateTime Canonical URL: https://androidmacro.com/docs/reference/datetime Source file: /docs/reference/datetime/_category_.json --- Learn the most important android macro concepts. ## Pages - [DateTime():add()](https://androidmacro.com/docs/reference/datetime/add.md) - [DateTime():date()](https://androidmacro.com/docs/reference/datetime/date.md) - [DateTime()](https://androidmacro.com/docs/reference/datetime/datetime.md) - [DateTime():day()](https://androidmacro.com/docs/reference/datetime/day.md) - [DateTime():diff()](https://androidmacro.com/docs/reference/datetime/diff.md) - [DateTime():endOf()](https://androidmacro.com/docs/reference/datetime/endof.md) - [DateTime():format()](https://androidmacro.com/docs/reference/datetime/format.md) - [DateTime():hour()](https://androidmacro.com/docs/reference/datetime/hour.md) - [DateTime():isAfter()](https://androidmacro.com/docs/reference/datetime/isafter.md) - [DateTime():isBefore()](https://androidmacro.com/docs/reference/datetime/isbefore.md) - [DateTime():isBetween()](https://androidmacro.com/docs/reference/datetime/isbetween.md) - [DateTime():isSame()](https://androidmacro.com/docs/reference/datetime/issame.md) - [DateTime():isSameOrAfter()](https://androidmacro.com/docs/reference/datetime/issameorafter.md) - [DateTime():isSameOrBefore()](https://androidmacro.com/docs/reference/datetime/issameorbefore.md) - [DateTime():local()](https://androidmacro.com/docs/reference/datetime/local.md) - [DateTime():millisecond()](https://androidmacro.com/docs/reference/datetime/millisecond.md) - [DateTime():minute()](https://androidmacro.com/docs/reference/datetime/minute.md) - [DateTime():month()](https://androidmacro.com/docs/reference/datetime/month.md) - [DateTime():second()](https://androidmacro.com/docs/reference/datetime/second.md) - [DateTime():date()](https://androidmacro.com/docs/reference/datetime/set-date.md) - [DateTime():hour()](https://androidmacro.com/docs/reference/datetime/set-hour.md) - [DateTime():millisecond()](https://androidmacro.com/docs/reference/datetime/set-millisecond.md) - [DateTime():minute()](https://androidmacro.com/docs/reference/datetime/set-minute.md) - [DateTime():month()](https://androidmacro.com/docs/reference/datetime/set-month.md) - [DateTime():second()](https://androidmacro.com/docs/reference/datetime/set-second.md) - [DateTime():year()](https://androidmacro.com/docs/reference/datetime/set-year.md) - [DateTime():startOf()](https://androidmacro.com/docs/reference/datetime/startof.md) - [DateTime():subtract()](https://androidmacro.com/docs/reference/datetime/subtract.md) - [DateTime():toISOString()](https://androidmacro.com/docs/reference/datetime/toisostring.md) - [DateTime():tz()](https://androidmacro.com/docs/reference/datetime/tz.md) - [DateTime():unix()](https://androidmacro.com/docs/reference/datetime/unix.md) - [DateTime():utc()](https://androidmacro.com/docs/reference/datetime/utc.md) - [DateTime():valueOf()](https://androidmacro.com/docs/reference/datetime/valueof.md) - [DateTime():year()](https://androidmacro.com/docs/reference/datetime/year.md) ## DateTime():add() Canonical URL: https://androidmacro.com/docs/reference/datetime/add Markdown URL: https://androidmacro.com/docs/reference/datetime/add.md # DateTime():add() Canonical URL: https://androidmacro.com/docs/reference/datetime/add Source file: /docs/reference/datetime/add.md --- Adds a specified amount of time to the DateTime object. ## Signature ```js add(amount: number, unit: string) ``` ## Parameters | Parameter | Type | Description | | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `amount` | `int` | The amount to add. | | `unit` | `String` | The unit of time to add. Supported units include: `years`, `year`, `months`, `month`, `weeks`, `week`, `days`, `day`, `hours`, `hour`, `minutes`, `minute`, `seconds`, `second`, `milliseconds`, `millisecond` | ## Returns - Type: `IDateTime` - The current `DateTime` instance, allowing for method chaining. ## Examples ```js local now = DateTime() -- Add 5 days now:add(5, "days") toast("Date after adding 5 days: " .. now:format("yyyy-MM-dd")) -- Add 2 months now = DateTime() -- Reset now:add(2, "months") toast("Date after adding 2 months: " .. now:format("yyyy-MM-dd")) ``` ## DateTime():date() Canonical URL: https://androidmacro.com/docs/reference/datetime/date Markdown URL: https://androidmacro.com/docs/reference/datetime/date.md # DateTime():date() Canonical URL: https://androidmacro.com/docs/reference/datetime/date Source file: /docs/reference/datetime/date.md --- Returns the day of the month of the `DateTime` object. #### Signature ```js date(): number ``` ## Returns - Type: `number` - The day of the month (1-31). ## Examples ```js local date = DateTime(2024, 1, 15, 10, 30, 0) local dayOfMonth = date:date() toast("Day of the month: " .. dayOfMonth) ``` ## DateTime() Canonical URL: https://androidmacro.com/docs/reference/datetime/datetime Markdown URL: https://androidmacro.com/docs/reference/datetime/datetime.md # DateTime() Canonical URL: https://androidmacro.com/docs/reference/datetime/datetime Source file: /docs/reference/datetime/datetime.md --- Utility class to perform datetime calculations ## Signature Creates a new DateTime instance representing the current date and time. ```js DateTime(); ``` Creates a new DateTime instance from a timestamp in milliseconds. ```js DateTime(timestamp: number) ``` Creates a new DateTime instance by parsing a date string. ```js DateTime(dateString: string) ``` Creates a new DateTime instance for the specified date at midnight (00:00:00). ```js DateTime(year: number, month: number, day: number) ``` Creates a new DateTime instance for the specified date and time. ```js DateTime(year: number, month: number, day: number, hour: number, minute: number, second: number) ``` ## Parameters | Parameter | Type | Description | | ------------ | -------- | -------------------------------------- | | `timestamp` | `number` | timestamp in milliseconds since epoch | | `dateString` | `string` | string representation of date to parse | | `year` | `number` | year value (e.g. 2024) | | `month` | `number` | month value (1-12) | | `day` | `number` | day of month (1-31) | | `hour` | `number` | hour of day (0-23) | | `minute` | `number` | minute of hour (0-59) | | `second` | `number` | second of minute (0-59) | ## Returns - Type: `DateTime` - A new `DateTime` instance. ## Examples ```js -- Create a DateTime object for the current date and time local now = DateTime() toast("Current DateTime: " .. now:format("yyyy-MM-dd HH:mm:ss")) -- Create a DateTime object from a timestamp local timestamp = 1678886400000 -- March 15, 2023 00:00:00 UTC local dateFromTimestamp = DateTime(timestamp) toast("DateTime from timestamp: " .. dateFromTimestamp:format("yyyy-MM-dd HH:mm:ss")) -- Create a DateTime object from a date string local dateFromString = DateTime("2023-03-15 10:30:00") toast("DateTime from string: " .. dateFromString:format("yyyy-MM-dd HH:mm:ss")) -- Create a DateTime object for a specific date local specificDate = DateTime(2023, 3, 15) toast("Specific Date: " .. specificDate:format("yyyy-MM-dd HH:mm:ss")) -- Create a DateTime object for a specific date and time local specificDateTime = DateTime(2023, 3, 15, 14, 45, 30) toast("Specific DateTime: " .. specificDateTime:format("yyyy-MM-dd HH:mm:ss")) ``` ## DateTime():day() Canonical URL: https://androidmacro.com/docs/reference/datetime/day Markdown URL: https://androidmacro.com/docs/reference/datetime/day.md # DateTime():day() Canonical URL: https://androidmacro.com/docs/reference/datetime/day Source file: /docs/reference/datetime/day.md --- Returns the day of the week of the `DateTime` object. (Sunday is 0, Monday is 1, etc.). #### Signature ```js day(): number ``` ## Returns - Type: `number` - The day of the week (0-6). ## Examples ```js local date = DateTime(2024, 1, 15, 10, 30, 0) -- A Tuesday local dayOfWeek = date:day() toast("Day of the week: " .. dayOfWeek) -- Output: 2 (Tuesday) ``` ## DateTime():diff() Canonical URL: https://androidmacro.com/docs/reference/datetime/diff Markdown URL: https://androidmacro.com/docs/reference/datetime/diff.md # DateTime():diff() Canonical URL: https://androidmacro.com/docs/reference/datetime/diff Source file: /docs/reference/datetime/diff.md --- Calculates the difference between the current DateTime object and another DateTime object. #### Signature ```js diff(other: DateTime): number ``` ```js diff(other: DateTime, unit: string): number ``` ## Parameters | Parameter | Type | Description | | ----------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `other` | `DateTime` | The other `DateTime` object to compare against. | | `unit` (Optional) | `string` | The unit of time for the difference. If not provided, the difference is returned in milliseconds. Supported units include `milliseconds`, `seconds`, `minutes`, `hours`, `days` | ## Returns - Type: `number` - The difference in milliseconds, or in the specified unit if provided. ## Examples ```js local date1 = DateTime(2024, 1, 10, 10, 0, 0) local date2 = DateTime(2024, 1, 10, 9, 0, 0) local diffMillis = date1:diff(date2) -- Difference in milliseconds toast("Difference in milliseconds: " .. diffMillis) local diffHours = date1:diff(date2, "hours") -- Difference in hours toast("Difference in hours: " .. diffHours) local diffDays = date1:diff(date2, "days") -- Difference in days toast("Difference in days: " .. diffDays) ``` ## DateTime():endOf() Canonical URL: https://androidmacro.com/docs/reference/datetime/endof Markdown URL: https://androidmacro.com/docs/reference/datetime/endof.md # DateTime():endOf() Canonical URL: https://androidmacro.com/docs/reference/datetime/endof Source file: /docs/reference/datetime/endof.md --- Sets the DateTime object to the end of a specified unit of time (e.g., end of the day, end of the month). #### Signature ```js endOf(unit: string): DateTime ``` ## Parameters | Parameter | Type | Description | | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------- | | `unit` | `String` | The unit of time to set the end of. Supported units include:`year`, `month`, `week`, `day`, `hour`, `minute`, `second` | ## Returns - Type: `DateTime` - The current `DateTime` instance, allowing for method chaining. ## Examples ```js local now = DateTime() -- Set to the end of the current day now:endOf("day") toast("End of day: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS")) -- Set to the end of the current month now = DateTime() -- Reset now:endOf("month") toast("End of month: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS")) -- Set to the end of the current year now = DateTime() -- Reset now:endOf("year") toast("End of year: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS")) ``` ## DateTime():format() Canonical URL: https://androidmacro.com/docs/reference/datetime/format Markdown URL: https://androidmacro.com/docs/reference/datetime/format.md # DateTime():format() Canonical URL: https://androidmacro.com/docs/reference/datetime/format Source file: /docs/reference/datetime/format.md --- Returns the formatted date as a string. #### Signature ```js format(pattern: string): string ``` ```js format(): string ``` ## Parameters | Parameter | Type | Description | | -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `pattern` (Optional) | `string` | The format pattern to apply. If not provided, a default format is used. Accepted formats include:`yyyy-MM-dd'T'HH:mm:ss.SSSZ`, `yyyy-MM-dd'T'HH:mm:ssZ`, `yyyy-MM-dd'T'HH:mm:ss`, `yyyy-MM-dd HH:mm:ss`, `yyyy-MM-dd`, `MM/dd/yyyy`, `dd/MM/yyyy`, `yyyy/MM/dd` | ## Returns - Type: `string` - The formatted date string. ## Examples ```js local now = DateTime() -- Format with a specific pattern local formattedDate1 = now:format("yyyy-MM-dd HH:mm:ss") toast("Formatted Date (yyyy-MM-dd HH:mm:ss): " .. formattedDate1) -- Format with a different pattern local formattedDate2 = now:format("MM/dd/yyyy") toast("Formatted Date (MM/dd/yyyy): " .. formattedDate2) -- Format with default pattern (if no pattern is provided) local formattedDate3 = now:format() toast("Formatted Date (default): " .. formattedDate3) ``` ## DateTime():hour() Canonical URL: https://androidmacro.com/docs/reference/datetime/hour Markdown URL: https://androidmacro.com/docs/reference/datetime/hour.md # DateTime():hour() Canonical URL: https://androidmacro.com/docs/reference/datetime/hour Source file: /docs/reference/datetime/hour.md --- Returns the hour of the day of the `DateTime` object. (24-hour format, 0-23). #### Signature ```js hour(): number ``` ## Returns - Type: number - The hour (0-23). ## Examples ```js local date = DateTime(2024, 1, 15, 14, 30, 0) -- 2:30 PM local hourOfDay = date:hour() toast("Hour of the day: " .. hourOfDay) -- Output: 14 ``` ## DateTime():isAfter() Canonical URL: https://androidmacro.com/docs/reference/datetime/isafter Markdown URL: https://androidmacro.com/docs/reference/datetime/isafter.md # DateTime():isAfter() Canonical URL: https://androidmacro.com/docs/reference/datetime/isafter Source file: /docs/reference/datetime/isafter.md --- Checks if the current DateTime object is after another DateTime object. #### Signature ```js isAfter(other: DateTime): boolean ``` ## Parameters | Parameter | Type | Description | | --------- | ---------- | ----------------------------------------------- | | `other` | `DateTime` | The other `DateTime` object to compare against. | ## Returns - Type: `boolean` - `true` if the current `DateTime` is strictly after the `other` DateTime, `false` otherwise. ## Examples ```js local date1 = DateTime(2024, 1, 10) local date2 = DateTime(2024, 1, 5) local result1 = date1:isAfter(date2) -- result will be true toast(tostring(result1)) local result2 = date2:isAfter(date1) -- result will be false toast(tostring(result2)) ``` ## DateTime():isBefore() Canonical URL: https://androidmacro.com/docs/reference/datetime/isbefore Markdown URL: https://androidmacro.com/docs/reference/datetime/isbefore.md # DateTime():isBefore() Canonical URL: https://androidmacro.com/docs/reference/datetime/isbefore Source file: /docs/reference/datetime/isbefore.md --- Checks if the current DateTime object is before another DateTime object. #### Signature ```js isBefore(other: DateTime): boolean ``` ## Parameters | Parameter | Type | Description | | --------- | ---------- | ----------------------------------------------- | | `other` | `DateTime` | The other `DateTime` object to compare against. | ## Returns - Type: `boolean` - `true` if the current `DateTime` is strictly before the `other` DateTime, `false` otherwise. ## Examples ```js local date1 = DateTime(2024, 1, 5) local date2 = DateTime(2024, 1, 10) local result1 = date1:isBefore(date2) -- result will be true toast(tostring(result1)) local result2 = date2:isBefore(date1) -- result will be false toast(tostring(result2)) ``` ## DateTime():isBetween() Canonical URL: https://androidmacro.com/docs/reference/datetime/isbetween Markdown URL: https://androidmacro.com/docs/reference/datetime/isbetween.md # DateTime():isBetween() Canonical URL: https://androidmacro.com/docs/reference/datetime/isbetween Source file: /docs/reference/datetime/isbetween.md --- Checks if the current DateTime object is between two other DateTime objects (inclusive). #### Signature ```js isBetween(start: DateTime, end: DateTime): boolean ``` ## Parameters | Parameter | Type | Description | | --------- | ---------- | ---------------------------- | | `start` | `DateTime` | The start `DateTime` object. | | `end` | `DateTime` | The end `DateTime` object. | ## Returns - Type: `boolean` - `true` if the current `DateTime` is between `start` and `end` (inclusive), `false` otherwise. ## Examples ```js local date = DateTime(2024, 1, 15) local start = DateTime(2024, 1, 10) local end_date = DateTime(2024, 1, 20) local result1 = date:isBetween(start, end_date) -- result will be true toast(tostring(result1)) local dateOutside = DateTime(2024, 1, 25) local result2 = dateOutside:isBetween(start, end_date) -- result will be false toast(tostring(result2)) ``` ## DateTime():isSame() Canonical URL: https://androidmacro.com/docs/reference/datetime/issame Markdown URL: https://androidmacro.com/docs/reference/datetime/issame.md # DateTime():isSame() Canonical URL: https://androidmacro.com/docs/reference/datetime/issame Source file: /docs/reference/datetime/issame.md --- Checks if the current DateTime object is the same as another DateTime object. #### Signature ```js isSame(other: DateTime): boolean ``` ## Parameters | Parameter | Type | Description | | --------- | ---------- | ----------------------------------------------- | | `other` | `DateTime` | The other `DateTime` object to compare against. | ## Returns - Type: `boolean` - `true` if the current `DateTime` is the same as the `other` DateTime, `false` otherwise. ## Examples ```js local date1 = DateTime(2024, 1, 10, 10, 30, 0) local date2 = DateTime(2024, 1, 10, 10, 30, 0) local date3 = DateTime(2024, 1, 10, 11, 0, 0) local result1 = date1:isSame(date2) -- result will be true toast(tostring(result1)) local result2 = date1:isSame(date3) -- result will be false toast(tostring(result2)) ``` ## DateTime():isSameOrAfter() Canonical URL: https://androidmacro.com/docs/reference/datetime/issameorafter Markdown URL: https://androidmacro.com/docs/reference/datetime/issameorafter.md # DateTime():isSameOrAfter() Canonical URL: https://androidmacro.com/docs/reference/datetime/issameorafter Source file: /docs/reference/datetime/issameorafter.md --- Checks if the current DateTime object is the same as or after another DateTime object. #### Signature ```js isSameOrAfter(other: DateTime): boolean ``` ## Parameters | Parameter | Type | Description | | --------- | ---------- | ----------------------------------------------- | | `other` | `DateTime` | The other `DateTime` object to compare against. | ## Returns - Type: `boolean` - `true` if the current `DateTime` is the same as or after the `other` DateTime, `false` otherwise. ## Examples ```js local date1 = DateTime(2024, 1, 10) local date2 = DateTime(2024, 1, 5) local date3 = DateTime(2024, 1, 10) local result1 = date1:isSameOrAfter(date2) -- result will be true toast(tostring(result1)) local result2 = date1:isSameOrAfter(date3) -- result will be true toast(tostring(result2)) local result3 = date2:isSameOrAfter(date1) -- result will be false toast(tostring(result3)) ``` ## DateTime():isSameOrBefore() Canonical URL: https://androidmacro.com/docs/reference/datetime/issameorbefore Markdown URL: https://androidmacro.com/docs/reference/datetime/issameorbefore.md # DateTime():isSameOrBefore() Canonical URL: https://androidmacro.com/docs/reference/datetime/issameorbefore Source file: /docs/reference/datetime/issameorbefore.md --- Checks if the current DateTime object is the same as or before another DateTime object. #### Signature ```js isSameOrBefore(other: DateTime): boolean ``` ## Parameters | Parameter | Type | Description | | --------- | ---------- | ----------------------------------------------- | | `other` | `DateTime` | The other `DateTime` object to compare against. | ## Returns - Type: `boolean` - `true` if the current `DateTime` is the same as or before the `other` DateTime, `false` otherwise. ## Examples ```js local date1 = DateTime(2024, 1, 5) local date2 = DateTime(2024, 1, 10) local date3 = DateTime(2024, 1, 5) local result1 = date1:isSameOrBefore(date2) -- result will be true toast(tostring(result1)) local result2 = date1:isSameOrBefore(date3) -- result will be true toast(tostring(result2)) local result3 = date2:isSameOrBefore(date1) -- result will be false toast(tostring(result3)) ``` ## DateTime():local() Canonical URL: https://androidmacro.com/docs/reference/datetime/local Markdown URL: https://androidmacro.com/docs/reference/datetime/local.md # DateTime():local() Canonical URL: https://androidmacro.com/docs/reference/datetime/local Source file: /docs/reference/datetime/local.md --- Converts the DateTime object's timezone to the system's default local timezone. #### Signature ```js local(): DateTime ``` ## Returns - Type: `DateTime` - The current `DateTime` instance, with its timezone set to the local default, allowing for method chaining. ## Examples ```js local now = DateTime() -- Assuming current system timezone is not UTC now:utc() toast("UTC time: " .. now:format("yyyy-MM-dd HH:mm:ss Z")) now:local() toast("Local time: " .. now:format("yyyy-MM-dd HH:mm:ss Z")) ``` ## DateTime():millisecond() Canonical URL: https://androidmacro.com/docs/reference/datetime/millisecond Markdown URL: https://androidmacro.com/docs/reference/datetime/millisecond.md # DateTime():millisecond() Canonical URL: https://androidmacro.com/docs/reference/datetime/millisecond Source file: /docs/reference/datetime/millisecond.md --- Returns the millisecond of the second of the `DateTime` object. #### Signature ```js millisecond(): number ``` ## Returns - Type: number - The millisecond (0-999). ## Examples ```js local date = DateTime(2024, 1, 15, 14, 30, 45, 123) local millisecond = date:millisecond() toast("Millisecond: " .. millisecond) -- Output: 123 ``` ## DateTime():minute() Canonical URL: https://androidmacro.com/docs/reference/datetime/minute Markdown URL: https://androidmacro.com/docs/reference/datetime/minute.md # DateTime():minute() Canonical URL: https://androidmacro.com/docs/reference/datetime/minute Source file: /docs/reference/datetime/minute.md --- Returns the minute of the hour of the `DateTime` object. #### Signature ```js minute(): number ``` ## Returns - Type: number - The minute (0-59). ## Examples ```js local date = DateTime(2024, 1, 15, 14, 30, 0) local minute = date:minute() toast("Minute: " .. minute) -- Output: 30 ``` ## DateTime():month() Canonical URL: https://androidmacro.com/docs/reference/datetime/month Markdown URL: https://androidmacro.com/docs/reference/datetime/month.md # DateTime():month() Canonical URL: https://androidmacro.com/docs/reference/datetime/month Source file: /docs/reference/datetime/month.md --- Returns the month of the `DateTime` object. (1-based, January is 1). #### Signature ```js month(): number ``` ## Returns - Type: number - The month (1-12). ## Examples ```js local date = DateTime(2024, 3, 15) -- March 15, 2024 local month = date:month() toast("Month: " .. month) -- Output: 3 ``` ## DateTime():second() Canonical URL: https://androidmacro.com/docs/reference/datetime/second Markdown URL: https://androidmacro.com/docs/reference/datetime/second.md # DateTime():second() Canonical URL: https://androidmacro.com/docs/reference/datetime/second Source file: /docs/reference/datetime/second.md --- Returns the second of the minute of the `DateTime` object. #### Signature ```js second(): number ``` ## Returns - Type: number - The second (0-59). ## Examples ```js local date = DateTime(2024, 1, 15, 14, 30, 45) local second = date:second() toast("Second: " .. second) -- Output: 45 ``` ## DateTime():date() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-date Markdown URL: https://androidmacro.com/docs/reference/datetime/set-date.md # DateTime():date() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-date Source file: /docs/reference/datetime/set-date.md --- Sets the day of the month of the `DateTime` object. #### Signature ```js date(date: number): DateTime ``` ## Parameters | Parameter | Type | Description | | --------- | -------- | ----------------------------------- | | `date` | `number` | The day of the month to set (1-31). | ## Returns - Type: `DateTime` - The current `DateTime` instance for chaining. ## Examples ```js local date = DateTime(2024, 1, 15) date:date(20) toast("New date: " .. date:format("yyyy-MM-dd")) -- Output: 2024-01-20 ``` ## DateTime():hour() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-hour Markdown URL: https://androidmacro.com/docs/reference/datetime/set-hour.md # DateTime():hour() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-hour Source file: /docs/reference/datetime/set-hour.md --- Sets the hour of the day of the `DateTime` object. (24-hour format, 0-23). #### Signature ```js hour(hour: number): DateTime ``` #### Parameters | Parameters | Type | Description | | ---------- | ---------- | ----------------------- | | hour | `number` | The hour to set (0-23). | **Returns** `DateTime` - The current `DateTime` instance for chaining. ## DateTime():millisecond() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-millisecond Markdown URL: https://androidmacro.com/docs/reference/datetime/set-millisecond.md # DateTime():millisecond() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-millisecond Source file: /docs/reference/datetime/set-millisecond.md --- Sets the millisecond of the second of the `DateTime` object. #### Signature ```js millisecond(millisecond: number): DateTime ``` #### Parameters | Parameters | Type | Description | | ----------- | -------- | ------------------------------- | | millisecond | `number` | The millisecond to set (0-999). | **Returns** `DateTime` - The current `DateTime` instance for chaining. ## DateTime():minute() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-minute Markdown URL: https://androidmacro.com/docs/reference/datetime/set-minute.md # DateTime():minute() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-minute Source file: /docs/reference/datetime/set-minute.md --- Sets the minute of the hour of the `DateTime` object. #### Signature ```js minute(minute: number): DateTime ``` #### Parameters | Parameters | Type | Description | | ---------- | -------- | ------------------------- | | minute | `number` | The minute to set (0-59). | **Returns** `DateTime` - The current `DateTime` instance for chaining. ## DateTime():month() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-month Markdown URL: https://androidmacro.com/docs/reference/datetime/set-month.md # DateTime():month() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-month Source file: /docs/reference/datetime/set-month.md --- Sets the month of the `DateTime` object. (1-based, January is 1). #### Signature ```js month(month: number): DateTime ``` #### Parameters | Parameters | Type | Description | | ---------- | -------- | ------------------------ | | month | `number` | The month to set (1-12). | **Returns** `DateTime` - The current `DateTime` instance for chaining. ## DateTime():second() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-second Markdown URL: https://androidmacro.com/docs/reference/datetime/set-second.md # DateTime():second() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-second Source file: /docs/reference/datetime/set-second.md --- Sets the second of the minute of the `DateTime` object. #### Signature ```js second(second: number): DateTime ``` #### Parameters | Parameters | Type | Description | | ---------- | -------- | ------------------------- | | second | `number` | The second to set (0-59). | **Returns** `DateTime` - The current `DateTime` instance for chaining. ## DateTime():year() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-year Markdown URL: https://androidmacro.com/docs/reference/datetime/set-year.md # DateTime():year() Canonical URL: https://androidmacro.com/docs/reference/datetime/set-year Source file: /docs/reference/datetime/set-year.md --- Sets the year of the `DateTime` object. #### Signature ```js year(year: number): DateTime ``` #### Parameters | Parameters | Type | Description | | ---------- | -------- | ---------------- | | year | `number` | The year to set. | **Returns** `DateTime` - The current `DateTime` instance for chaining. ## DateTime():startOf() Canonical URL: https://androidmacro.com/docs/reference/datetime/startof Markdown URL: https://androidmacro.com/docs/reference/datetime/startof.md # DateTime():startOf() Canonical URL: https://androidmacro.com/docs/reference/datetime/startof Source file: /docs/reference/datetime/startof.md --- Sets the DateTime object to the start of a specified unit of time (e.g., start of the day, start of the month). #### Signature ```js startOf(unit: string): DateTime ``` ## Parameters | Parameter | Type | Description | | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------ | | `unit` | `string` | The unit of time to set the start of. Supported units include:`year`, `month`, `week`, `day`, `hour`, `minute`, `second` | ## Returns - Type: `DateTime` - The current `DateTime` instance, allowing for method chaining. ## Examples ```js local now = DateTime() -- Set to the start of the current day now:startOf("day") toast("Start of day: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS")) -- Set to the start of the current month now = DateTime() -- Reset now:startOf("month") toast("Start of month: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS")) -- Set to the start of the current year now = DateTime() -- Reset now:startOf("year") toast("Start of year: " .. now:format("yyyy-MM-dd HH:mm:ss.SSS")) ``` ## DateTime():subtract() Canonical URL: https://androidmacro.com/docs/reference/datetime/subtract Markdown URL: https://androidmacro.com/docs/reference/datetime/subtract.md # DateTime():subtract() Canonical URL: https://androidmacro.com/docs/reference/datetime/subtract Source file: /docs/reference/datetime/subtract.md --- Subtracts a specified amount of time from the DateTime object. #### Signature ```js subtract(amount: number, unit: string): DateTime ``` ## Parameters | Parameter | Type | Description | | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `amount` | `number` | The amount to subtract. | | `unit` | `string` | The unit of time to subtract. Supported units include:`years`, `year`, `months`, `month`, `weeks`, `week`, `days`, `day`, `hours`, `hour`, `minutes`, `minute`, `seconds`, `second`, `milliseconds`, `millisecond` | ## Returns - Type: `DateTime` - The current `DateTime` instance, allowing for method chaining. ## Examples ```js local now = DateTime() -- Subtract 5 days now:subtract(5, "days") toast("Date after subtracting 5 days: " .. now:format("yyyy-MM-dd")) -- Subtract 2 months now = DateTime() -- Reset now:subtract(2, "months") toast("Date after subtracting 2 months: " .. now:format("yyyy-MM-dd")) ``` ## DateTime():toISOString() Canonical URL: https://androidmacro.com/docs/reference/datetime/toisostring Markdown URL: https://androidmacro.com/docs/reference/datetime/toisostring.md # DateTime():toISOString() Canonical URL: https://androidmacro.com/docs/reference/datetime/toisostring Source file: /docs/reference/datetime/toisostring.md --- Returns the ISO 8601 formatted date string (e.g., "1970-01-01T00:00:00.000Z"). #### Signature ```js toISOString(): string ``` ## Returns - Type: `string` - The ISO 8601 formatted date string. ## Examples ```js local now = DateTime() local isoString = now:toISOString() toast("ISO String: " .. isoString) -- e.g., "2024-01-15T10:30:00.000Z" ``` ## DateTime():tz() Canonical URL: https://androidmacro.com/docs/reference/datetime/tz Markdown URL: https://androidmacro.com/docs/reference/datetime/tz.md # DateTime():tz() Canonical URL: https://androidmacro.com/docs/reference/datetime/tz Source file: /docs/reference/datetime/tz.md --- Sets the DateTime object's timezone to a specified timezone ID. #### Signature ```js tz(timeZoneId: string): DateTime ``` ## Parameters | Parameter | Type | Description | | ------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `timeZoneId` | `string` | The ID of the timezone to set (e.g., "America/New_York", "Europe/London"). A list of available timezone IDs can be found[here](https://docs.oracle.com/javase/8/docs/api/java/time/ZoneId.html#of-java.lang.String-). | ## Returns - Type: `DateTime` - The current `DateTime` instance, with its timezone set to the specified ID, allowing for method chaining. ## Examples ```js local now = DateTime() toast("Local time: " .. now:format("yyyy-MM-dd HH:mm:ss Z")) now:tz("America/New_York") toast("New York time: " .. now:format("yyyy-MM-dd HH:mm:ss Z")) now:tz("Europe/London") toast("London time: " .. now:format("yyyy-MM-dd HH:mm:ss Z")) ``` ## DateTime():unix() Canonical URL: https://androidmacro.com/docs/reference/datetime/unix Markdown URL: https://androidmacro.com/docs/reference/datetime/unix.md # DateTime():unix() Canonical URL: https://androidmacro.com/docs/reference/datetime/unix Source file: /docs/reference/datetime/unix.md --- Returns the Unix timestamp (seconds since Unix epoch) of the `DateTime` object. #### Signature ```js unix(): number ``` **Returns** number - The Unix timestamp in seconds. ## DateTime():utc() Canonical URL: https://androidmacro.com/docs/reference/datetime/utc Markdown URL: https://androidmacro.com/docs/reference/datetime/utc.md # DateTime():utc() Canonical URL: https://androidmacro.com/docs/reference/datetime/utc Source file: /docs/reference/datetime/utc.md --- Converts the DateTime object's timezone to UTC. #### Signature ```js utc(): DateTime ``` ## Returns - Type: `DateTime` - The current `DateTime` instance, with its timezone set to UTC, allowing for method chaining. ## Examples ```js local now = DateTime() toast("Local time: " .. now:format("yyyy-MM-dd HH:mm:ss Z")) now:utc() toast("UTC time: " .. now:format("yyyy-MM-dd HH:mm:ss Z")) ``` ## DateTime():valueOf() Canonical URL: https://androidmacro.com/docs/reference/datetime/valueof Markdown URL: https://androidmacro.com/docs/reference/datetime/valueof.md # DateTime():valueOf() Canonical URL: https://androidmacro.com/docs/reference/datetime/valueof Source file: /docs/reference/datetime/valueof.md --- Returns the primitive value of the `DateTime` object, which is the number of milliseconds since the Unix epoch. #### Signature ```js valueOf(): number ``` ## Returns - Type: `number` - The number of milliseconds since the Unix epoch. ## Examples ```js local now = DateTime() local milliseconds = now:valueOf() toast("Milliseconds since epoch: " .. milliseconds) -- e.g., 1705301400123 ``` ## DateTime():year() Canonical URL: https://androidmacro.com/docs/reference/datetime/year Markdown URL: https://androidmacro.com/docs/reference/datetime/year.md # DateTime():year() Canonical URL: https://androidmacro.com/docs/reference/datetime/year Source file: /docs/reference/datetime/year.md --- Returns the year of the `DateTime` object. #### Signature ```js year(): number ``` ## Returns - Type: `number` - The year (e.g., 2024). ## Examples ```js local date = DateTime(2024, 1, 15) local year = date:year() toast("Year: " .. year) -- Output: 2024 ``` ## Dialog Canonical URL: https://androidmacro.com/docs/reference/dialog Markdown URL: https://androidmacro.com/docs/reference/dialog.md # Dialog Canonical URL: https://androidmacro.com/docs/reference/dialog Source file: /docs/reference/dialog/_category_.json --- Learn the most important android macro concepts. ## Pages - [Dialog:add()](https://androidmacro.com/docs/reference/dialog/add.md) - [Dialog:getValueById()](https://androidmacro.com/docs/reference/dialog/getvaluebyid.md) - [Dialog:getValueOf()](https://androidmacro.com/docs/reference/dialog/getvalueof.md) - [Dialog:init()](https://androidmacro.com/docs/reference/dialog/init.md) - [Dialog:remove()](https://androidmacro.com/docs/reference/dialog/remove.md) - [Dialog:setMessage()](https://androidmacro.com/docs/reference/dialog/setmessage.md) - [Dialog:setTitle()](https://androidmacro.com/docs/reference/dialog/settitle.md) - [Dialog:show()](https://androidmacro.com/docs/reference/dialog/show.md) ## Dialog:add() Canonical URL: https://androidmacro.com/docs/reference/dialog/add Markdown URL: https://androidmacro.com/docs/reference/dialog/add.md # Dialog:add() Canonical URL: https://androidmacro.com/docs/reference/dialog/add Source file: /docs/reference/dialog/add.md --- Add view to the dialog, currently you can only add view based on this parameter #### Signature ```js Dialog:add(view: EditText | Column | CheckBox | Row | RadioGroup | TextView): void ``` **Returns** `void` ## Dialog:getValueById() Canonical URL: https://androidmacro.com/docs/reference/dialog/getvaluebyid Markdown URL: https://androidmacro.com/docs/reference/dialog/getvaluebyid.md # Dialog:getValueById() Canonical URL: https://androidmacro.com/docs/reference/dialog/getvaluebyid Source file: /docs/reference/dialog/getvaluebyid.md --- This method is useful to get the value of `EditText`, `CheckBox`, `RadioGroup` based on id #### Signature ```js Dialog:getValueById(id: number): string | boolean | number ``` **Returns** `string` or `boolean` or `number` ## Dialog:getValueOf() Canonical URL: https://androidmacro.com/docs/reference/dialog/getvalueof Markdown URL: https://androidmacro.com/docs/reference/dialog/getvalueof.md # Dialog:getValueOf() Canonical URL: https://androidmacro.com/docs/reference/dialog/getvalueof Source file: /docs/reference/dialog/getvalueof.md --- This method is useful to get the value of `EditText`, `CheckBox`, `RadioGroup` #### Signature ```js Dialog:getValueOf(view: EditText | CheckBox | RadioGroup): string | boolean | number ``` **Returns** `string` or `boolean` or `number` ## Dialog:init() Canonical URL: https://androidmacro.com/docs/reference/dialog/init Markdown URL: https://androidmacro.com/docs/reference/dialog/init.md # Dialog:init() Canonical URL: https://androidmacro.com/docs/reference/dialog/init Source file: /docs/reference/dialog/init.md --- To start using and displaying the dialog, this method is required to initialize the dialog #### Signature ```js Dialog:init(): void ``` **Returns** `void` ## Dialog:remove() Canonical URL: https://androidmacro.com/docs/reference/dialog/remove Markdown URL: https://androidmacro.com/docs/reference/dialog/remove.md # Dialog:remove() Canonical URL: https://androidmacro.com/docs/reference/dialog/remove Source file: /docs/reference/dialog/remove.md --- Remove view from dialog view based on it's id #### Signature ```js Dialog:remove(id: number): void ``` **Returns** `void` ## Dialog:setMessage() Canonical URL: https://androidmacro.com/docs/reference/dialog/setmessage Markdown URL: https://androidmacro.com/docs/reference/dialog/setmessage.md # Dialog:setMessage() Canonical URL: https://androidmacro.com/docs/reference/dialog/setmessage Source file: /docs/reference/dialog/setmessage.md --- Add body content text to the dialog view #### Signature ```js Dialog:setMessage(message: string): void ``` **Returns** `void` ## Dialog:setTitle() Canonical URL: https://androidmacro.com/docs/reference/dialog/settitle Markdown URL: https://androidmacro.com/docs/reference/dialog/settitle.md # Dialog:setTitle() Canonical URL: https://androidmacro.com/docs/reference/dialog/settitle Source file: /docs/reference/dialog/settitle.md --- Add title to the dialog view #### Signature ```js Dialog:setTitle(title: string): void ``` **Returns** `void` ## Dialog:show() Canonical URL: https://androidmacro.com/docs/reference/dialog/show Markdown URL: https://androidmacro.com/docs/reference/dialog/show.md # Dialog:show() Canonical URL: https://androidmacro.com/docs/reference/dialog/show Source file: /docs/reference/dialog/show.md --- If you invoke this function the dialog will popup in the screen #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------------------------------------------------------- | | timeoutMs | number | Optional timeout in milliseconds before the dialog auto-confirms | #### Signature ```js Dialog:show(): void ``` ```js Dialog:show(timeoutMs: number): void ``` **Returns** `void` ## Description `Dialog:show()` displays the dialog and waits for the user to press `OK` or `Cancel`. If you pass `timeoutMs`, the dialog will automatically trigger the positive button after the given delay. This is useful when you want to show parameters briefly but continue execution automatically. ## Examples ```js Dialog:init() Dialog:setTitle("Confirm action") Dialog:setMessage("Press OK to continue") Dialog:show() ``` ```js Dialog:init() Dialog:setTitle("Quick notice") Dialog:setMessage("This dialog will continue automatically") Dialog:show(3000) ``` ## Notes - `Dialog:show()` is equivalent to `Dialog:show(0)` - A timeout value greater than `0` enables auto-confirm behavior - If the user cancels or dismisses the dialog, macro execution throws an exception ## EditText Canonical URL: https://androidmacro.com/docs/reference/edittext Markdown URL: https://androidmacro.com/docs/reference/edittext.md # EditText Canonical URL: https://androidmacro.com/docs/reference/edittext Source file: /docs/reference/edittext/_category_.json --- Learn the most important android macro concepts. ## Pages - [EditText()](https://androidmacro.com/docs/reference/edittext/edittext.md) - [EditText():getHint()](https://androidmacro.com/docs/reference/edittext/gethint.md) - [EditText():getHint()](https://androidmacro.com/docs/reference/edittext/gettextcolor.md) - [EditText():getTextSize()](https://androidmacro.com/docs/reference/edittext/gettextsize.md) ## EditText() Canonical URL: https://androidmacro.com/docs/reference/edittext/edittext Markdown URL: https://androidmacro.com/docs/reference/edittext/edittext.md # EditText() Canonical URL: https://androidmacro.com/docs/reference/edittext/edittext Source file: /docs/reference/edittext/edittext.md --- Add EditText to dialog view ## Constructor ```js EditText(id: number, hint: string) ``` ```js EditText(id: number, hint: string, defaultValue: string) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ------------------------------------------------------------------------------ | | id | number | Unique identifier of the input text, the id is used in `Dialog:getValueById()` | | hint | string | Custom hint text of Input Text | | defaultValue | string | Optional default text shown when the dialog opens | ## Notes - The third parameter is optional - If `defaultValue` is provided, it is used as the initial value for the field - When a default value is provided, it takes priority over previously saved dialog state ## EditText():getHint() Canonical URL: https://androidmacro.com/docs/reference/edittext/gethint Markdown URL: https://androidmacro.com/docs/reference/edittext/gethint.md # EditText():getHint() Canonical URL: https://androidmacro.com/docs/reference/edittext/gethint Source file: /docs/reference/edittext/gethint.md --- Will return the hint text of EditText #### Signature ```js getHint(): string ``` **Returns** `string` ## EditText():getHint() Canonical URL: https://androidmacro.com/docs/reference/edittext/gettextcolor Markdown URL: https://androidmacro.com/docs/reference/edittext/gettextcolor.md # EditText():getHint() Canonical URL: https://androidmacro.com/docs/reference/edittext/gettextcolor Source file: /docs/reference/edittext/gettextcolor.md --- # EditText():getTextColor() Will return the color text #### Signature ```js getTextColor(): number ``` **Returns** `number` ## EditText():getTextSize() Canonical URL: https://androidmacro.com/docs/reference/edittext/gettextsize Markdown URL: https://androidmacro.com/docs/reference/edittext/gettextsize.md # EditText():getTextSize() Canonical URL: https://androidmacro.com/docs/reference/edittext/gettextsize Source file: /docs/reference/edittext/gettextsize.md --- Will return the text size of EditText #### Signature ```js getTextSize(): number ``` **Returns** `number` ## FinderParams Canonical URL: https://androidmacro.com/docs/reference/finder-params Markdown URL: https://androidmacro.com/docs/reference/finder-params.md # FinderParams Canonical URL: https://androidmacro.com/docs/reference/finder-params Source file: /docs/reference/finder-params/_category_.json --- Learn the most important android macro concepts. ## Pages - [FinderParams()](https://androidmacro.com/docs/reference/finder-params/find-params.md) - [FinderParams():getDelay()](https://androidmacro.com/docs/reference/finder-params/getdelay.md) - [FinderParams():getDetectionEngine()](https://androidmacro.com/docs/reference/finder-params/getdetectionengine.md) - [FinderParams():getDetectionMethod()](https://androidmacro.com/docs/reference/finder-params/getdetectionmethod.md) - [FinderParams():getDetectionType()](https://androidmacro.com/docs/reference/finder-params/getdetectiontype.md) - [FinderParams():getHighlightDuration()](https://androidmacro.com/docs/reference/finder-params/gethighlightduration.md) - [FinderParams():getHighlightTooltip()](https://androidmacro.com/docs/reference/finder-params/gethighlighttooltip.md) - [FinderParams():getScore()](https://androidmacro.com/docs/reference/finder-params/getscore.md) - [FinderParams():isDynamicScaling()](https://androidmacro.com/docs/reference/finder-params/isdynamicscaling.md) - [FinderParams():isGrayscale()](https://androidmacro.com/docs/reference/finder-params/isgrayscale.md) - [FinderParams():isHighlight()](https://androidmacro.com/docs/reference/finder-params/ishighlight.md) - [FinderParams():setDelay()](https://androidmacro.com/docs/reference/finder-params/setdelay.md) - [FinderParams():setDetectionEngine()](https://androidmacro.com/docs/reference/finder-params/setdetectionengine.md) - [FinderParams():setDetectionMethod()](https://androidmacro.com/docs/reference/finder-params/setdetectionmethod.md) - [FinderParams():setDetectionType()](https://androidmacro.com/docs/reference/finder-params/setdetectiontype.md) - [FinderParams():setDynamicScaling()](https://androidmacro.com/docs/reference/finder-params/setdynamicscaling.md) - [FinderParams():setGrayscale()](https://androidmacro.com/docs/reference/finder-params/setgrayscale.md) - [FinderParams():setHighlight()](https://androidmacro.com/docs/reference/finder-params/sethighlight.md) - [FinderParams():setHighlightDuration()](https://androidmacro.com/docs/reference/finder-params/sethighlightduration.md) - [FinderParams():setHighlightTooltip()](https://androidmacro.com/docs/reference/finder-params/sethighlighttooltip.md) - [FinderParams():setScore()](https://androidmacro.com/docs/reference/finder-params/setscore.md) ## FinderParams() Canonical URL: https://androidmacro.com/docs/reference/finder-params/find-params Markdown URL: https://androidmacro.com/docs/reference/finder-params/find-params.md # FinderParams() Canonical URL: https://androidmacro.com/docs/reference/finder-params/find-params Source file: /docs/reference/finder-params/find-params.md --- Useful to parameterize search detection ## Constructor ``` FinderParams() ``` This class will initialize default parameter for image/text search events ## FinderParams():getDelay() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdelay Markdown URL: https://androidmacro.com/docs/reference/finder-params/getdelay.md # FinderParams():getDelay() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdelay Source file: /docs/reference/finder-params/getdelay.md --- Will return the delay of detection #### Signature ```js getDelay(): number ``` **Returns** `number` ## FinderParams():getDetectionEngine() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdetectionengine Markdown URL: https://androidmacro.com/docs/reference/finder-params/getdetectionengine.md # FinderParams():getDetectionEngine() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdetectionengine Source file: /docs/reference/finder-params/getdetectionengine.md --- Get the current detection engine ID **For Text Recognition** - `1` = ML-Kit - `2` = PP-OCR **For Image Recognition** - `1` = OpenCV #### Signature ```js getDetectionEngine(): number ``` **Returns** `number` ## FinderParams():getDetectionMethod() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdetectionmethod Markdown URL: https://androidmacro.com/docs/reference/finder-params/getdetectionmethod.md # FinderParams():getDetectionMethod() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdetectionmethod Source file: /docs/reference/finder-params/getdetectionmethod.md --- Will return the detection method **For Text Recognition** - `1` = "WORD INCASE SENSITIVE" (Default) - `2` = "LINE INCASE SENSITIVE" - `3` = "WORD CASE SENSITIVE" - `4` = "LINE CASE SENSITIVE" - `5` = "WORD EXACT MATCH" - `6` = "LINE EXACT MATCH" **For Image Recognition** - `1` = "Correlation Coefficient" (Default) - `2` = "Cross Correlation" - `3` = "Square Difference" #### Signature ```js getDetectionMethod(): number ``` **Returns** `number` ## FinderParams():getDetectionType() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdetectiontype Markdown URL: https://androidmacro.com/docs/reference/finder-params/getdetectiontype.md # FinderParams():getDetectionType() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getdetectiontype Source file: /docs/reference/finder-params/getdetectiontype.md --- Will return the detection type which is `IMAGE` or `TEXT` in string #### Signature ```js getDetectionType(): string ``` **Returns** `string` ## FinderParams():getHighlightDuration() Canonical URL: https://androidmacro.com/docs/reference/finder-params/gethighlightduration Markdown URL: https://androidmacro.com/docs/reference/finder-params/gethighlightduration.md # FinderParams():getHighlightDuration() Canonical URL: https://androidmacro.com/docs/reference/finder-params/gethighlightduration Source file: /docs/reference/finder-params/gethighlightduration.md --- Get the highlight duration #### Signature ```js getHighlightDuration(): number ``` **Returns** `number` ## FinderParams():getHighlightTooltip() Canonical URL: https://androidmacro.com/docs/reference/finder-params/gethighlighttooltip Markdown URL: https://androidmacro.com/docs/reference/finder-params/gethighlighttooltip.md # FinderParams():getHighlightTooltip() Canonical URL: https://androidmacro.com/docs/reference/finder-params/gethighlighttooltip Source file: /docs/reference/finder-params/gethighlighttooltip.md --- Check if highlight tooltip is enabled #### Signature ```js getHighlightTooltip(): boolean ``` **Returns** `boolean` ## FinderParams():getScore() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getscore Markdown URL: https://androidmacro.com/docs/reference/finder-params/getscore.md # FinderParams():getScore() Canonical URL: https://androidmacro.com/docs/reference/finder-params/getscore Source file: /docs/reference/finder-params/getscore.md --- Will return the detection score threshold #### Signature ```js getScore(): number ``` **Returns** `number` ## FinderParams():isDynamicScaling() Canonical URL: https://androidmacro.com/docs/reference/finder-params/isdynamicscaling Markdown URL: https://androidmacro.com/docs/reference/finder-params/isdynamicscaling.md # FinderParams():isDynamicScaling() Canonical URL: https://androidmacro.com/docs/reference/finder-params/isdynamicscaling Source file: /docs/reference/finder-params/isdynamicscaling.md --- Check if dynamic scaling is enabled #### Signature ```js isDynamicScaling(): boolean ``` **Returns** `boolean` ## FinderParams():isGrayscale() Canonical URL: https://androidmacro.com/docs/reference/finder-params/isgrayscale Markdown URL: https://androidmacro.com/docs/reference/finder-params/isgrayscale.md # FinderParams():isGrayscale() Canonical URL: https://androidmacro.com/docs/reference/finder-params/isgrayscale Source file: /docs/reference/finder-params/isgrayscale.md --- This method return boolean indicating the image/text search will be performed in grayscale #### Signature ```js isGrayscale(): boolean ``` **Returns** `boolean` ## FinderParams():isHighlight() Canonical URL: https://androidmacro.com/docs/reference/finder-params/ishighlight Markdown URL: https://androidmacro.com/docs/reference/finder-params/ishighlight.md # FinderParams():isHighlight() Canonical URL: https://androidmacro.com/docs/reference/finder-params/ishighlight Source file: /docs/reference/finder-params/ishighlight.md --- Will return boolean whether detection will be highlighted or not #### Signature ```js isHighlight(): boolean ``` **Returns** `boolean` ## FinderParams():setDelay() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdelay Markdown URL: https://androidmacro.com/docs/reference/finder-params/setdelay.md # FinderParams():setDelay() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdelay Source file: /docs/reference/finder-params/setdelay.md --- You can set image/text search delay in milliseconds using this method #### Signature ```js setDelay(ms: number): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setDetectionEngine() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdetectionengine Markdown URL: https://androidmacro.com/docs/reference/finder-params/setdetectionengine.md # FinderParams():setDetectionEngine() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdetectionengine Source file: /docs/reference/finder-params/setdetectionengine.md --- Set the underlying detection engine ID **For Text Recognition** - `1` = ML-Kit - `2` = PP-OCR **For Image Recognition** - `1` = OpenCV #### Signature ```js setDetectionEngine(engine: number): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setDetectionMethod() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdetectionmethod Markdown URL: https://androidmacro.com/docs/reference/finder-params/setdetectionmethod.md # FinderParams():setDetectionMethod() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdetectionmethod Source file: /docs/reference/finder-params/setdetectionmethod.md --- Modify the detection algorithm **For Text Recognition** - `1` = "WORD INCASE SENSITIVE" (Default) - `2` = "LINE INCASE SENSITIVE" - `3` = "WORD CASE SENSITIVE" - `4` = "LINE CASE SENSITIVE" - `5` = "WORD EXACT MATCH" - `6` = "LINE EXACT MATCH" **For Image Recognition** - `1` = "Correlation Coefficient" (Default) - `2` = "Cross Correlation" - `3` = "Square Difference" #### Signature ```js setDetectionMethod(method: number): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setDetectionType() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdetectiontype Markdown URL: https://androidmacro.com/docs/reference/finder-params/setdetectiontype.md # FinderParams():setDetectionType() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdetectiontype Source file: /docs/reference/finder-params/setdetectiontype.md --- Modify the detection behaviour which is `IMAGE` or `TEXT` in string. By default `IMAGE` is used #### Signature ```js setDetectionType(type: string): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setDynamicScaling() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdynamicscaling Markdown URL: https://androidmacro.com/docs/reference/finder-params/setdynamicscaling.md # FinderParams():setDynamicScaling() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setdynamicscaling Source file: /docs/reference/finder-params/setdynamicscaling.md --- Set whether to use dynamic scaling during detection (useful for multiscreen support) #### Signature ```js setDynamicScaling(scaling: boolean): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setGrayscale() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setgrayscale Markdown URL: https://androidmacro.com/docs/reference/finder-params/setgrayscale.md # FinderParams():setGrayscale() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setgrayscale Source file: /docs/reference/finder-params/setgrayscale.md --- Set whether to use grayscale conversion for detection #### Signature ```js setGrayscale(grayscale: boolean): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setHighlight() Canonical URL: https://androidmacro.com/docs/reference/finder-params/sethighlight Markdown URL: https://androidmacro.com/docs/reference/finder-params/sethighlight.md # FinderParams():setHighlight() Canonical URL: https://androidmacro.com/docs/reference/finder-params/sethighlight Source file: /docs/reference/finder-params/sethighlight.md --- This parameter will tell the macro to show the highlight of the detection in your device screen #### Signature ```js setHighlight(highlight: boolean): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setHighlightDuration() Canonical URL: https://androidmacro.com/docs/reference/finder-params/sethighlightduration Markdown URL: https://androidmacro.com/docs/reference/finder-params/sethighlightduration.md # FinderParams():setHighlightDuration() Canonical URL: https://androidmacro.com/docs/reference/finder-params/sethighlightduration Source file: /docs/reference/finder-params/sethighlightduration.md --- Set the duration of the highlight in milliseconds #### Signature ```js setHighlightDuration(ms: number): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setHighlightTooltip() Canonical URL: https://androidmacro.com/docs/reference/finder-params/sethighlighttooltip Markdown URL: https://androidmacro.com/docs/reference/finder-params/sethighlighttooltip.md # FinderParams():setHighlightTooltip() Canonical URL: https://androidmacro.com/docs/reference/finder-params/sethighlighttooltip Source file: /docs/reference/finder-params/sethighlighttooltip.md --- Set whether to show a tooltip with the highlight #### Signature ```js setHighlightTooltip(show: boolean): FinderParams ``` **Returns** `FinderParams` ## FinderParams():setScore() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setscore Markdown URL: https://androidmacro.com/docs/reference/finder-params/setscore.md # FinderParams():setScore() Canonical URL: https://androidmacro.com/docs/reference/finder-params/setscore Source file: /docs/reference/finder-params/setscore.md --- Set the threshold score for image and text recognition #### Signature ```js setScore(score: number): FinderParams ``` **Returns** `FinderParams` ## Keyboard Canonical URL: https://androidmacro.com/docs/reference/keyboard Markdown URL: https://androidmacro.com/docs/reference/keyboard.md # Keyboard Canonical URL: https://androidmacro.com/docs/reference/keyboard Source file: /docs/reference/keyboard/_category_.json --- Learn the most important android macro concepts. ## Pages - [Keyboard](https://androidmacro.com/docs/reference/keyboard/keyboard.md) - [Keyboard:type()](https://androidmacro.com/docs/reference/keyboard/type.md) ## Keyboard Canonical URL: https://androidmacro.com/docs/reference/keyboard/keyboard Markdown URL: https://androidmacro.com/docs/reference/keyboard/keyboard.md # Keyboard Canonical URL: https://androidmacro.com/docs/reference/keyboard/keyboard Source file: /docs/reference/keyboard/keyboard.md --- Useful module to type text into your device screen ## Keyboard:type() Canonical URL: https://androidmacro.com/docs/reference/keyboard/type Markdown URL: https://androidmacro.com/docs/reference/keyboard/type.md # Keyboard:type() Canonical URL: https://androidmacro.com/docs/reference/keyboard/type Source file: /docs/reference/keyboard/type.md --- This method will simulate keyboard typing to your screen, but only works on any text input not working in some apps #### Signature ```js Keyboard:type(text: string): void ``` **Returns** `void` ## Macro Canonical URL: https://androidmacro.com/docs/reference/macro Markdown URL: https://androidmacro.com/docs/reference/macro.md # Macro Canonical URL: https://androidmacro.com/docs/reference/macro Source file: /docs/reference/macro/_category_.json --- Learn the most important android macro concepts. ## Pages - [Macro():executeBlock()](https://androidmacro.com/docs/reference/macro/executeblock.md) - [Macro():executeCode()](https://androidmacro.com/docs/reference/macro/executecode.md) - [Macro():getBlock()](https://androidmacro.com/docs/reference/macro/getblock.md) - [Macro():getCode()](https://androidmacro.com/docs/reference/macro/getcode.md) - [Macro():getId()](https://androidmacro.com/docs/reference/macro/getid.md) - [Macro:getList()](https://androidmacro.com/docs/reference/macro/getlist.md) - [Macro():getName()](https://androidmacro.com/docs/reference/macro/getname.md) - [Macro()](https://androidmacro.com/docs/reference/macro/macro.md) ## Macro():executeBlock() Canonical URL: https://androidmacro.com/docs/reference/macro/executeblock Markdown URL: https://androidmacro.com/docs/reference/macro/executeblock.md # Macro():executeBlock() Canonical URL: https://androidmacro.com/docs/reference/macro/executeblock Source file: /docs/reference/macro/executeblock.md --- Execute your macro using block executor #### Signature ```js executeBlock(): void ``` **Returns** `void` **Compatible Version**: `1.0.0.26` and up ## Macro():executeCode() Canonical URL: https://androidmacro.com/docs/reference/macro/executecode Markdown URL: https://androidmacro.com/docs/reference/macro/executecode.md # Macro():executeCode() Canonical URL: https://androidmacro.com/docs/reference/macro/executecode Source file: /docs/reference/macro/executecode.md --- Execute your macro using code executor #### Signature ```js executeCode(): void ``` **Returns** `void` **Compatible Version**: `1.0.0.26` and up ## Macro():getBlock() Canonical URL: https://androidmacro.com/docs/reference/macro/getblock Markdown URL: https://androidmacro.com/docs/reference/macro/getblock.md # Macro():getBlock() Canonical URL: https://androidmacro.com/docs/reference/macro/getblock Source file: /docs/reference/macro/getblock.md --- Get the `xml` block of the coresponding macro #### Signature ```js getBlock(): string ``` **Returns** `string` **Compatible Version**: `1.0.0.26` and up ## Macro():getCode() Canonical URL: https://androidmacro.com/docs/reference/macro/getcode Markdown URL: https://androidmacro.com/docs/reference/macro/getcode.md # Macro():getCode() Canonical URL: https://androidmacro.com/docs/reference/macro/getcode Source file: /docs/reference/macro/getcode.md --- Get the code of the coresponding macro #### Signature ```js getCode(): string ``` **Returns** `string` **Compatible Version**: `1.0.0.26` and up ## Macro():getId() Canonical URL: https://androidmacro.com/docs/reference/macro/getid Markdown URL: https://androidmacro.com/docs/reference/macro/getid.md # Macro():getId() Canonical URL: https://androidmacro.com/docs/reference/macro/getid Source file: /docs/reference/macro/getid.md --- Get the id of the coresponding macro #### Signature ```js getId(): string ``` **Returns** `string` **Compatible Version**: `1.0.0.26` and up ## Macro:getList() Canonical URL: https://androidmacro.com/docs/reference/macro/getlist Markdown URL: https://androidmacro.com/docs/reference/macro/getlist.md # Macro:getList() Canonical URL: https://androidmacro.com/docs/reference/macro/getlist Source file: /docs/reference/macro/getlist.md --- Get the list of your existing macro #### Signature ```js Macro:getList(): List ``` **Returns** `List` **Compatible Version**: `1.0.0.26` and up ## Macro():getName() Canonical URL: https://androidmacro.com/docs/reference/macro/getname Markdown URL: https://androidmacro.com/docs/reference/macro/getname.md # Macro():getName() Canonical URL: https://androidmacro.com/docs/reference/macro/getname Source file: /docs/reference/macro/getname.md --- Get the name of the coresponding macro #### Signature ```js getName(): string ``` **Returns** `string` **Compatible Version**: `1.0.0.26` and up ## Macro() Canonical URL: https://androidmacro.com/docs/reference/macro/macro Markdown URL: https://androidmacro.com/docs/reference/macro/macro.md # Macro() Canonical URL: https://androidmacro.com/docs/reference/macro/macro Source file: /docs/reference/macro/macro.md --- An extension module for calling or executing your macro programatically at runtime ## Constructor ```js Macro(id: string) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ------------ | | id | string | The macro id | ## MatchResult Canonical URL: https://androidmacro.com/docs/reference/match-result Markdown URL: https://androidmacro.com/docs/reference/match-result.md # MatchResult Canonical URL: https://androidmacro.com/docs/reference/match-result Source file: /docs/reference/match-result/_category_.json --- Learn the most important android macro concepts. ## Pages - [MatchResult:getMiddleX()](https://androidmacro.com/docs/reference/match-result/getmiddlex.md) - [MatchResult:getMiddleY()](https://androidmacro.com/docs/reference/match-result/getmiddley.md) - [MatchResult:getPoint()](https://androidmacro.com/docs/reference/match-result/getpoint.md) - [MatchResult:getRegion()](https://androidmacro.com/docs/reference/match-result/getregion.md) - [MatchResult:getScore()](https://androidmacro.com/docs/reference/match-result/getscore.md) - [MatchResult:getText()](https://androidmacro.com/docs/reference/match-result/gettext.md) - [MatchResult:getX()](https://androidmacro.com/docs/reference/match-result/getx.md) - [MatchResult:getY()](https://androidmacro.com/docs/reference/match-result/gety.md) ## MatchResult:getMiddleX() Canonical URL: https://androidmacro.com/docs/reference/match-result/getmiddlex Markdown URL: https://androidmacro.com/docs/reference/match-result/getmiddlex.md # MatchResult:getMiddleX() Canonical URL: https://androidmacro.com/docs/reference/match-result/getmiddlex Source file: /docs/reference/match-result/getmiddlex.md --- Returns the X coordinate of the center point of the matched region. ## Description The `getMiddleX()` method returns the horizontal center position (X coordinate) of the matched area. This is useful when you want to perform actions like clicking on the center of the matched image or text. The center X coordinate is calculated as: `getX() + (getWidth() / 2)` #### Signature ```js getMiddleX(): number ``` **Returns** `number` - The X coordinate (in pixels) of the center point of the matched region. ## Example ```js local result = Screen:find("button.png") if result then local centerX = result:getMiddleX() local centerY = result:getMiddleY() -- Click on the center of the match Screen:click(centerX, centerY) end ``` ## MatchResult:getMiddleY() Canonical URL: https://androidmacro.com/docs/reference/match-result/getmiddley Markdown URL: https://androidmacro.com/docs/reference/match-result/getmiddley.md # MatchResult:getMiddleY() Canonical URL: https://androidmacro.com/docs/reference/match-result/getmiddley Source file: /docs/reference/match-result/getmiddley.md --- Returns the Y coordinate of the center point of the matched region. ## Description The `getMiddleY()` method returns the vertical center position (Y coordinate) of the matched area. This is useful when you want to perform actions like clicking on the center of the matched image or text. The center Y coordinate is calculated as: `getY() + (getHeight() / 2)` #### Signature ```js getMiddleY(): number ``` **Returns** `number` - The Y coordinate (in pixels) of the center point of the matched region. ## Example ```js local result = Screen:find("button.png") if result then local centerX = result:getMiddleX() local centerY = result:getMiddleY() -- Click on the center of the match Screen:click(centerX, centerY) end ``` ## MatchResult:getPoint() Canonical URL: https://androidmacro.com/docs/reference/match-result/getpoint Markdown URL: https://androidmacro.com/docs/reference/match-result/getpoint.md # MatchResult:getPoint() Canonical URL: https://androidmacro.com/docs/reference/match-result/getpoint Source file: /docs/reference/match-result/getpoint.md --- Returns the center point of the matched region as a Point object. ## Description The `getPoint()` method returns a `Point` object representing the center coordinates of the matched area. This is a convenient way to get both the X and Y center coordinates at once, and the returned Point can be used directly with touch methods. The center point coordinates are equivalent to `getMiddleX()` and `getMiddleY()`. #### Signature ```js getPoint(): Point ``` **Returns** `Point` - A Point object containing the center X and Y coordinates of the matched region. ## Example ```js local result = Screen:find("button.png") if result then local point = result:getPoint() -- Use the point directly for tapping Screen:click(point) end ``` ## MatchResult:getRegion() Canonical URL: https://androidmacro.com/docs/reference/match-result/getregion Markdown URL: https://androidmacro.com/docs/reference/match-result/getregion.md # MatchResult:getRegion() Canonical URL: https://androidmacro.com/docs/reference/match-result/getregion Source file: /docs/reference/match-result/getregion.md --- Returns the matched region as a Region object. ## Description The `getRegion()` method returns a `Region` object that represents the rectangular area where the match was found. This region includes the position (X, Y) of the top-left corner and the dimensions (width, height) of the matched area. The returned Region can be used to: - Perform further searches within the matched area - Capture a screenshot of just the matched region - Define a sub-region for other operations - Build a fitted search area for faster repeated matching #### Signature ```js getRegion(): Region ``` **Returns** `Region` - A Region object representing the rectangular bounds of the matched area. ## Example ```js local result = Screen:find("container.png") if result then local region = result:getRegion() toast("Region: X=" .. region:getX() .. ", Y=" .. region:getY()) toast("Size: " .. region:getWidth() .. "x" .. region:getHeight()) -- Search within the matched region for faster matching local innerResult = region:find("container.png") if innerResult then toast("Found container.png inside region!") end end ``` ## Fit Region Technique `getRegion()` is the key method behind an important optimization pattern often called `fit region`. The pattern is: 1. Find a stable object on `Screen` 2. Call `getRegion()` on the `MatchResult` 3. Reuse that region for repeated searches inside the same object ```js local panel = Screen:find("reward-panel.jpg") if panel then local fitRegion = panel:getRegion() -- Search only inside the fitted panel instead of the full screen local claim = fitRegion:find("claim-button.jpg") if claim then fitRegion:click("claim-button.jpg") end end ``` This technique works best when the matched object always has roughly the same size. It can reduce processing cost significantly because you avoid repeating full-screen searches for every step inside the same container. ## MatchResult:getScore() Canonical URL: https://androidmacro.com/docs/reference/match-result/getscore Markdown URL: https://androidmacro.com/docs/reference/match-result/getscore.md # MatchResult:getScore() Canonical URL: https://androidmacro.com/docs/reference/match-result/getscore Source file: /docs/reference/match-result/getscore.md --- Returns the confidence score of the match. ## Description The `getScore()` method returns a decimal value representing how closely the found region matches the search template. A higher score indicates a better match. - For image matching, the score typically ranges from `0.0` to `1.0`, where `1.0` represents a perfect match. - The default match threshold is usually around `0.8` (80% confidence). This is useful for filtering results based on match quality or for debugging purposes. #### Signature ```js getScore(): number ``` **Returns** `number` - The confidence score of the match (typically between 0.0 and 1.0). ## Example ```js local result = Screen:find("template.png") if result then local score = result:getScore() toast("Match confidence: " .. (score * 100) .. "%") -- Only proceed if confidence is high enough if score >= 0.9 then toast("High confidence match found!") end end ``` ## MatchResult:getText() Canonical URL: https://androidmacro.com/docs/reference/match-result/gettext Markdown URL: https://androidmacro.com/docs/reference/match-result/gettext.md # MatchResult:getText() Canonical URL: https://androidmacro.com/docs/reference/match-result/gettext Source file: /docs/reference/match-result/gettext.md --- Returns the label or text associated with the match. ## Description The `getText()` method returns a string label associated with the matched result. This is particularly useful when: - Performing text-based searches (OCR) where the recognized text is returned - Working with labeled templates where you want to identify which template was matched If no label is associated with the match, this method returns an empty string. #### Signature ```js getText(): string ``` **Returns** `string` - The label or text associated with the match, or an empty string if none. ## Example ```js -- Example with OCR text search local result = Screen:find("hello World", FinderParams():setDetectionType("TEXT")) if result then local text = result:getText() toast("Found text: " .. text) end -- Example checking for specific text local result = Screen:find("submit", FinderParams():setDetectionType("TEXT")) if result then local label = result:getText() if label == "submit" then toast("Found submit button!") end end ``` ## MatchResult:getX() Canonical URL: https://androidmacro.com/docs/reference/match-result/getx Markdown URL: https://androidmacro.com/docs/reference/match-result/getx.md # MatchResult:getX() Canonical URL: https://androidmacro.com/docs/reference/match-result/getx Source file: /docs/reference/match-result/getx.md --- Returns the X coordinate of the top-left corner of the matched region. ## Description The `getX()` method returns the horizontal position (X coordinate) of the top-left corner where the match was found on the screen. This value represents the pixel position from the left edge of the screen. #### Signature ```js getX(): number ``` **Returns** `number` - The X coordinate (in pixels) of the top-left corner of the matched region. ## Example ```js local result = Screen:find("template.png") if result then local x = result:getX() toast("Match found at X position: " .. x) end ``` ## MatchResult:getY() Canonical URL: https://androidmacro.com/docs/reference/match-result/gety Markdown URL: https://androidmacro.com/docs/reference/match-result/gety.md # MatchResult:getY() Canonical URL: https://androidmacro.com/docs/reference/match-result/gety Source file: /docs/reference/match-result/gety.md --- Returns the Y coordinate of the top-left corner of the matched region. ## Description The `getY()` method returns the vertical position (Y coordinate) of the top-left corner where the match was found on the screen. This value represents the pixel position from the top edge of the screen. #### Signature ```js getY(): number ``` **Returns** `number` - The Y coordinate (in pixels) of the top-left corner of the matched region. ## Example ```js local result = Screen:find("template.png") if result then local y = result:getY() toast("Match found at Y position: " .. y) end ``` ## Point Canonical URL: https://androidmacro.com/docs/reference/point Markdown URL: https://androidmacro.com/docs/reference/point.md # Point Canonical URL: https://androidmacro.com/docs/reference/point Source file: /docs/reference/point/_category_.json --- Learn the most important android macro concepts. ## Pages - [Point():getX()](https://androidmacro.com/docs/reference/point/getx.md) - [Point():getY()](https://androidmacro.com/docs/reference/point/gety.md) - [Point()](https://androidmacro.com/docs/reference/point/point.md) - [Point():setX()](https://androidmacro.com/docs/reference/point/setx.md) - [Point():setY()](https://androidmacro.com/docs/reference/point/sety.md) ## Point():getX() Canonical URL: https://androidmacro.com/docs/reference/point/getx Markdown URL: https://androidmacro.com/docs/reference/point/getx.md # Point():getX() Canonical URL: https://androidmacro.com/docs/reference/point/getx Source file: /docs/reference/point/getx.md --- Will return the x coordinate #### Signature ```js getX(): number ``` **Returns** `number` ## Point():getY() Canonical URL: https://androidmacro.com/docs/reference/point/gety Markdown URL: https://androidmacro.com/docs/reference/point/gety.md # Point():getY() Canonical URL: https://androidmacro.com/docs/reference/point/gety Source file: /docs/reference/point/gety.md --- Will return the y coordinate #### Signature ```js getY(): number ``` **Returns** `number` ## Point() Canonical URL: https://androidmacro.com/docs/reference/point/point Markdown URL: https://androidmacro.com/docs/reference/point/point.md # Point() Canonical URL: https://androidmacro.com/docs/reference/point/point Source file: /docs/reference/point/point.md --- Coordinate of x and y in screen ## Constructor ``` Point(x: number, y: number) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------- | | x | number | The x coordinate | | y | number | The y coordinate | ## Point():setX() Canonical URL: https://androidmacro.com/docs/reference/point/setx Markdown URL: https://androidmacro.com/docs/reference/point/setx.md # Point():setX() Canonical URL: https://androidmacro.com/docs/reference/point/setx Source file: /docs/reference/point/setx.md --- Modify the x coordinate #### Signature ```js setX(x: number): void ``` **Returns** `void` ## Point():setY() Canonical URL: https://androidmacro.com/docs/reference/point/sety Markdown URL: https://androidmacro.com/docs/reference/point/sety.md # Point():setY() Canonical URL: https://androidmacro.com/docs/reference/point/sety Source file: /docs/reference/point/sety.md --- Modify the y coordinate #### Signature ```js setY(y: number): void ``` **Returns** `void` ## RadioButton Canonical URL: https://androidmacro.com/docs/reference/radio-button Markdown URL: https://androidmacro.com/docs/reference/radio-button.md # RadioButton Canonical URL: https://androidmacro.com/docs/reference/radio-button Source file: /docs/reference/radio-button/_category_.json --- Learn the most important android macro concepts. ## Pages - [RadioButton():getId()](https://androidmacro.com/docs/reference/radio-button/getid.md) - [RadioButton():getText()](https://androidmacro.com/docs/reference/radio-button/gettext.md) - [RadioButton()](https://androidmacro.com/docs/reference/radio-button/radio-button.md) ## RadioButton():getId() Canonical URL: https://androidmacro.com/docs/reference/radio-button/getid Markdown URL: https://androidmacro.com/docs/reference/radio-button/getid.md # RadioButton():getId() Canonical URL: https://androidmacro.com/docs/reference/radio-button/getid Source file: /docs/reference/radio-button/getid.md --- Will return the button id #### Signature ```js getId(): number ``` **Returns** `number` ## RadioButton():getText() Canonical URL: https://androidmacro.com/docs/reference/radio-button/gettext Markdown URL: https://androidmacro.com/docs/reference/radio-button/gettext.md # RadioButton():getText() Canonical URL: https://androidmacro.com/docs/reference/radio-button/gettext Source file: /docs/reference/radio-button/gettext.md --- Will return the text of radio button #### Signature ```js getText(): string ``` **Returns** `string` ## RadioButton() Canonical URL: https://androidmacro.com/docs/reference/radio-button/radio-button Markdown URL: https://androidmacro.com/docs/reference/radio-button/radio-button.md # RadioButton() Canonical URL: https://androidmacro.com/docs/reference/radio-button/radio-button Source file: /docs/reference/radio-button/radio-button.md --- Add Radio button to dialog view ## Constructor ``` RadioButton(id: number, text: string) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ------------------------------------------------------------------------ | | id | number | Unique identifier or label of the button, the id is used by `RadioGroup` | | text | string | Text of radio button | ## RadioGroup Canonical URL: https://androidmacro.com/docs/reference/radio-group Markdown URL: https://androidmacro.com/docs/reference/radio-group.md # RadioGroup Canonical URL: https://androidmacro.com/docs/reference/radio-group Source file: /docs/reference/radio-group/_category_.json --- Learn the most important android macro concepts. ## Pages - [RadioGroup():add()](https://androidmacro.com/docs/reference/radio-group/add.md) - [RadioGroup():getButtons()](https://androidmacro.com/docs/reference/radio-group/getbuttons.md) - [RadioGroup():getId()](https://androidmacro.com/docs/reference/radio-group/getid.md) - [RadioGroup()](https://androidmacro.com/docs/reference/radio-group/radio-group.md) ## RadioGroup():add() Canonical URL: https://androidmacro.com/docs/reference/radio-group/add Markdown URL: https://androidmacro.com/docs/reference/radio-group/add.md # RadioGroup():add() Canonical URL: https://androidmacro.com/docs/reference/radio-group/add Source file: /docs/reference/radio-group/add.md --- Add radio button to the group #### Signature ```js add(button: RadioButton): void ``` **Returns** `void` ## RadioGroup():getButtons() Canonical URL: https://androidmacro.com/docs/reference/radio-group/getbuttons Markdown URL: https://androidmacro.com/docs/reference/radio-group/getbuttons.md # RadioGroup():getButtons() Canonical URL: https://androidmacro.com/docs/reference/radio-group/getbuttons Source file: /docs/reference/radio-group/getbuttons.md --- Will return the list of radio buttons #### Signature ```js getButtons(): List ``` **Returns** `List` ## RadioGroup():getId() Canonical URL: https://androidmacro.com/docs/reference/radio-group/getid Markdown URL: https://androidmacro.com/docs/reference/radio-group/getid.md # RadioGroup():getId() Canonical URL: https://androidmacro.com/docs/reference/radio-group/getid Source file: /docs/reference/radio-group/getid.md --- Will return the view id #### Signature ```js getId(): number ``` **Returns** `number` ## RadioGroup() Canonical URL: https://androidmacro.com/docs/reference/radio-group/radio-group Markdown URL: https://androidmacro.com/docs/reference/radio-group/radio-group.md # RadioGroup() Canonical URL: https://androidmacro.com/docs/reference/radio-group/radio-group Source file: /docs/reference/radio-group/radio-group.md --- Add radio group to dialog view, each child view contains Radio Button ## Constructor ```js RadioGroup(id: number) ``` ```js RadioGroup(id: number, defaultButtonId: number) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ----------------------------------------------------------------------------------- | | id | number | Unique identifier or label of the button, the id is used by `Dialog:getValueById()` | | defaultButtonId | number | Optional radio button id that should be selected by default | ## Notes - The second parameter is optional - `defaultButtonId` should match one of the `RadioButton` ids added into this group - If the provided button id is not found, the dialog falls back to the first radio button - When a default value is provided, it takes priority over previously saved dialog state ## Record Canonical URL: https://androidmacro.com/docs/reference/record Markdown URL: https://androidmacro.com/docs/reference/record.md # Record Canonical URL: https://androidmacro.com/docs/reference/record Source file: /docs/reference/record/_category_.json --- Learn the most important android macro concepts. ## Pages - [Record:play()](https://androidmacro.com/docs/reference/record/play.md) - [Record](https://androidmacro.com/docs/reference/record/record.md) ## Record:play() Canonical URL: https://androidmacro.com/docs/reference/record/play Markdown URL: https://androidmacro.com/docs/reference/record/play.md # Record:play() Canonical URL: https://androidmacro.com/docs/reference/record/play Source file: /docs/reference/record/play.md --- Execute your pre-recorded touch #### Signature ```js Record:play(recordName: string, params: RecordParams): void ``` **Returns** `void` ## Record Canonical URL: https://androidmacro.com/docs/reference/record/record Markdown URL: https://androidmacro.com/docs/reference/record/record.md # Record Canonical URL: https://androidmacro.com/docs/reference/record/record Source file: /docs/reference/record/record.md --- Useful module to replay your gestures/touches ## Region Canonical URL: https://androidmacro.com/docs/reference/region Markdown URL: https://androidmacro.com/docs/reference/region.md # Region Canonical URL: https://androidmacro.com/docs/reference/region Source file: /docs/reference/region/_category_.json --- Learn the most important android macro concepts. ## Pages - [Region():click()](https://androidmacro.com/docs/reference/region/click.md) - [Region():clickAll()](https://androidmacro.com/docs/reference/region/clickall.md) - [Region():exist()](https://androidmacro.com/docs/reference/region/exist.md) - [Region():existClick()](https://androidmacro.com/docs/reference/region/existclick.md) - [Region():existClickAll()](https://androidmacro.com/docs/reference/region/existclickall.md) - [Region():find()](https://androidmacro.com/docs/reference/region/find.md) - [Region():findAll()](https://androidmacro.com/docs/reference/region/findall.md) - [Region():getColor()](https://androidmacro.com/docs/reference/region/getcolor.md) - [Region():getColors()](https://androidmacro.com/docs/reference/region/getcolors.md) - [Region():getText()](https://androidmacro.com/docs/reference/region/gettext.md) - [Region():getTextMatches()](https://androidmacro.com/docs/reference/region/gettextmatches.md) - [Region():getX()](https://androidmacro.com/docs/reference/region/getx.md) - [Region():getY()](https://androidmacro.com/docs/reference/region/gety.md) - [Region():height()](https://androidmacro.com/docs/reference/region/height.md) - [Region():highlight()](https://androidmacro.com/docs/reference/region/highlight.md) - [Region():multiSwipe()](https://androidmacro.com/docs/reference/region/multiswipe.md) - [Region()](https://androidmacro.com/docs/reference/region/region.md) - [Region():screenshot()](https://androidmacro.com/docs/reference/region/screenshot.md) - [Region():swipe()](https://androidmacro.com/docs/reference/region/swipe.md) - [Region():wait()](https://androidmacro.com/docs/reference/region/wait.md) - [Region():waitClick()](https://androidmacro.com/docs/reference/region/waitclick.md) - [Region():waitVanish()](https://androidmacro.com/docs/reference/region/waitvanish.md) - [Region():width()](https://androidmacro.com/docs/reference/region/width.md) ## Region():click() Canonical URL: https://androidmacro.com/docs/reference/region/click Markdown URL: https://androidmacro.com/docs/reference/region/click.md # Region():click() Canonical URL: https://androidmacro.com/docs/reference/region/click Source file: /docs/reference/region/click.md --- To perform parameterize click behaviour using `MatchResult` #### Signature ```js click(match: MatchResult, params: ClickParams): void ``` ```js click(template: string, params: ClickParams): void ``` ```js click(point: Point, params: ClickParams): void ``` ```js click(x: number, y: number, params: ClickParams): void ``` **Returns** `void` ## Region():clickAll() Canonical URL: https://androidmacro.com/docs/reference/region/clickall Markdown URL: https://androidmacro.com/docs/reference/region/clickall.md # Region():clickAll() Canonical URL: https://androidmacro.com/docs/reference/region/clickall Source file: /docs/reference/region/clickall.md --- To perform image/text detection and click it's match coordinate in bulk manner #### Signature ```js clickAll(template: string, params: ClickParams): void ``` **Returns** `void` ## Region():exist() Canonical URL: https://androidmacro.com/docs/reference/region/exist Markdown URL: https://androidmacro.com/docs/reference/region/exist.md # Region():exist() Canonical URL: https://androidmacro.com/docs/reference/region/exist Source file: /docs/reference/region/exist.md --- To check if match exist in the region, if match is found then this method returns `true` else `false` #### Signature ```js exist(template: string): boolean ``` ```js exist(template: string, params: FinderParams): boolean ``` **Returns** `boolean` ## Region():existClick() Canonical URL: https://androidmacro.com/docs/reference/region/existclick Markdown URL: https://androidmacro.com/docs/reference/region/existclick.md # Region():existClick() Canonical URL: https://androidmacro.com/docs/reference/region/existclick Source file: /docs/reference/region/existclick.md --- To perform image/text detection and click it's match coordinate, if match is found then this method returns `true` #### Signature ```js existClick(match: MatchResult, params: ClickParams): boolean ``` ```js existClick(template: string, params: ClickParams): boolean ``` **Returns** `boolean` ## Region():existClickAll() Canonical URL: https://androidmacro.com/docs/reference/region/existclickall Markdown URL: https://androidmacro.com/docs/reference/region/existclickall.md # Region():existClickAll() Canonical URL: https://androidmacro.com/docs/reference/region/existclickall Source file: /docs/reference/region/existclickall.md --- To perform image/text detection and click it's match coordinate, if match is found then this method returns `true` #### Signature ```js existClickAll(template: string, params: ClickParams): boolean ``` **Returns** `boolean` ## Region():find() Canonical URL: https://androidmacro.com/docs/reference/region/find Markdown URL: https://androidmacro.com/docs/reference/region/find.md # Region():find() Canonical URL: https://androidmacro.com/docs/reference/region/find Source file: /docs/reference/region/find.md --- To perform image or text search in the region, if the image or text is found return the `MatchResult` else return `nil` #### Signature ```js find(template: string): MatchResult | nil ``` ```js find(template: string, params: FinderParams): MatchResult | nil ``` ```js find(template: string, timeout: number, params: FinderParams): MatchResult | nil ``` **Returns** `MatchResult` or `nil` ## Region():findAll() Canonical URL: https://androidmacro.com/docs/reference/region/findall Markdown URL: https://androidmacro.com/docs/reference/region/findall.md # Region():findAll() Canonical URL: https://androidmacro.com/docs/reference/region/findall Source file: /docs/reference/region/findall.md --- To perform image or text search in bulk manner and return a list of `MatchResult` #### Signature ```js findAll(template: string): List ``` ```js findAll(template: string, params: FinderParams): List ``` **Returns** `List` ## Region():getColor() Canonical URL: https://androidmacro.com/docs/reference/region/getcolor Markdown URL: https://androidmacro.com/docs/reference/region/getcolor.md # Region():getColor() Canonical URL: https://androidmacro.com/docs/reference/region/getcolor Source file: /docs/reference/region/getcolor.md --- To get color pixel in certain coordinate, later this color can be used to compare if color has similar score, this is useful to do color detection #### Signature ```js getColor(x: number, y: number): Color ``` ```js getColor(point: Point): Color ``` **Returns** `Color` ## Region():getColors() Canonical URL: https://androidmacro.com/docs/reference/region/getcolors Markdown URL: https://androidmacro.com/docs/reference/region/getcolors.md # Region():getColors() Canonical URL: https://androidmacro.com/docs/reference/region/getcolors Source file: /docs/reference/region/getcolors.md --- To get color pixel in multiple coordinates at the same time, later these colors can be used to compare if color has similar score, this is useful to do color detection #### Signature ```js getColors(points: List): List ``` **Returns** `List` ## Region():getText() Canonical URL: https://androidmacro.com/docs/reference/region/gettext Markdown URL: https://androidmacro.com/docs/reference/region/gettext.md # Region():getText() Canonical URL: https://androidmacro.com/docs/reference/region/gettext Source file: /docs/reference/region/gettext.md --- This method performs OCR in region of interest and return the concatenated text #### Signature ```js getText(params: FinderParams): string ``` **Returns** `string` ## Region():getTextMatches() Canonical URL: https://androidmacro.com/docs/reference/region/gettextmatches Markdown URL: https://androidmacro.com/docs/reference/region/gettextmatches.md # Region():getTextMatches() Canonical URL: https://androidmacro.com/docs/reference/region/gettextmatches Source file: /docs/reference/region/gettextmatches.md --- Get all text matches found in the region properly formatted #### Signature ```js getTextMatches(params: FinderParams): Match[] ``` **Returns** `Match[]` ## Region():getX() Canonical URL: https://androidmacro.com/docs/reference/region/getx Markdown URL: https://androidmacro.com/docs/reference/region/getx.md # Region():getX() Canonical URL: https://androidmacro.com/docs/reference/region/getx Source file: /docs/reference/region/getx.md --- Get the x coordinate of region #### Signature ```js getX(): number ``` **Returns** `number` ## Region():getY() Canonical URL: https://androidmacro.com/docs/reference/region/gety Markdown URL: https://androidmacro.com/docs/reference/region/gety.md # Region():getY() Canonical URL: https://androidmacro.com/docs/reference/region/gety Source file: /docs/reference/region/gety.md --- Get the y coordinate of region #### Signature ```js getY(): number ``` **Returns** `number` ## Region():height() Canonical URL: https://androidmacro.com/docs/reference/region/height Markdown URL: https://androidmacro.com/docs/reference/region/height.md # Region():height() Canonical URL: https://androidmacro.com/docs/reference/region/height Source file: /docs/reference/region/height.md --- Get the height of region #### Signature ```js height(): number ``` **Returns** `number` ## Region():highlight() Canonical URL: https://androidmacro.com/docs/reference/region/highlight Markdown URL: https://androidmacro.com/docs/reference/region/highlight.md # Region():highlight() Canonical URL: https://androidmacro.com/docs/reference/region/highlight Source file: /docs/reference/region/highlight.md --- Use for highlighting the region #### Signature ```js highlight(secs: number): void ``` **Returns** `void` ## Region():multiSwipe() Canonical URL: https://androidmacro.com/docs/reference/region/multiswipe Markdown URL: https://androidmacro.com/docs/reference/region/multiswipe.md # Region():multiSwipe() Canonical URL: https://androidmacro.com/docs/reference/region/multiswipe Source file: /docs/reference/region/multiswipe.md --- Perform up to 10 fingers swipe simultaneously within the region. Each finger operates on its own independent timeline. #### Signature ```js multiSwipe(fingers: List>): void ``` **Returns** `void` ## Parameters | Parameter | Type | Description | | --------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------- | | fingers | `List>` | A list of finger paths. Each finger path is a list of `SwipePoint` values. Minimum 2 points per finger. Maximum 10 fingers. | :::tip This method works the same as [`Screen:multiSwipe()`](/docs/reference/screen/multiswipe). See that page for detailed parameter behavior, timeline examples, and limits. ::: ## Example ```js local region = Region(0, 0, Screen:width(), Screen:height()) region:multiSwipe({ { SwipePoint(500, 800, 50, 0), SwipePoint(500, 400, 50, 1000), }, { SwipePoint(600, 800, 50, 0), SwipePoint(600, 400, 50, 1000), }, }) ``` ## Region() Canonical URL: https://androidmacro.com/docs/reference/region/region Markdown URL: https://androidmacro.com/docs/reference/region/region.md # Region() Canonical URL: https://androidmacro.com/docs/reference/region/region Source file: /docs/reference/region/region.md --- The core module for detecting and performing ui automation in a region of interest which is a part of screen device ## Constructor ``` Region(x: number, y: number, width: number, height: number) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ----------------------- | | x | number | The x coordinate | | y | number | The y coordinate | | width | number | The width bounding box | | height | number | The height bounding box | ## Region():screenshot() Canonical URL: https://androidmacro.com/docs/reference/region/screenshot Markdown URL: https://androidmacro.com/docs/reference/region/screenshot.md # Region():screenshot() Canonical URL: https://androidmacro.com/docs/reference/region/screenshot Source file: /docs/reference/region/screenshot.md --- Take a screenshot of region and save it to /data/data/com.androidmacro/images/$macroId/$fileName #### Signature ```js screenshot(fileName: string): void ``` **Returns** `void` ## Region():swipe() Canonical URL: https://androidmacro.com/docs/reference/region/swipe Markdown URL: https://androidmacro.com/docs/reference/region/swipe.md # Region():swipe() Canonical URL: https://androidmacro.com/docs/reference/region/swipe Source file: /docs/reference/region/swipe.md --- Perform a single-finger swipe within the region. #### Signature ```js swipe(swipePoints: List, params?: SwipeParams): void ``` **Returns** `void` ## Parameters | Parameter | Type | Description | | ----------- | ------------------ | -------------------------------------------------------------------- | | swipePoints | `List` | A list of points the finger moves through. Minimum 2 points. | | params | `SwipeParams` | Optional. Controls swipe behavior such as continuous mode and delay. | :::tip This method works the same as [`Screen:swipe()`](/docs/reference/screen/swipe). See that page for detailed parameter behavior, timeline examples, and SwipePoint defaults. ::: ## Example ```js local region = Region(0, 0, Screen:width(), Screen:height()) region:swipe({ SwipePoint(500, 1200, 50, 0), SwipePoint(500, 400, 50, 1000), }) ``` ## Region():wait() Canonical URL: https://androidmacro.com/docs/reference/region/wait Markdown URL: https://androidmacro.com/docs/reference/region/wait.md # Region():wait() Canonical URL: https://androidmacro.com/docs/reference/region/wait Source file: /docs/reference/region/wait.md --- Wait until template appear in the region, if timeout reached this method will throw an error #### Signature ```js wait(template: string): void ``` ```js wait(template: string, timeout: number): void ``` ```js wait(template: string, timeout: number, params: FinderParams): void ``` **Returns** `void` ## Region():waitClick() Canonical URL: https://androidmacro.com/docs/reference/region/waitclick Markdown URL: https://androidmacro.com/docs/reference/region/waitclick.md # Region():waitClick() Canonical URL: https://androidmacro.com/docs/reference/region/waitclick Source file: /docs/reference/region/waitclick.md --- Wait for an image/text to appear and then click it #### Signature ```js waitClick(template: string, timeout: number, params: ClickParams): void ``` **Returns** `void` ## Region():waitVanish() Canonical URL: https://androidmacro.com/docs/reference/region/waitvanish Markdown URL: https://androidmacro.com/docs/reference/region/waitvanish.md # Region():waitVanish() Canonical URL: https://androidmacro.com/docs/reference/region/waitvanish Source file: /docs/reference/region/waitvanish.md --- Wait until template disappear or vanish in the region, if timeout reached this method will throw an error #### Signature ```js waitVanish(template: string): void ``` ```js waitVanish(template: string, timeout: number): void ``` ```js waitVanish(template: string, timeout: number, params: FinderParams): void ``` **Returns** `void` ## Region():width() Canonical URL: https://androidmacro.com/docs/reference/region/width Markdown URL: https://androidmacro.com/docs/reference/region/width.md # Region():width() Canonical URL: https://androidmacro.com/docs/reference/region/width Source file: /docs/reference/region/width.md --- Get the width of region #### Signature ```js width(): number ``` **Returns** `number` ## Request Canonical URL: https://androidmacro.com/docs/reference/request Markdown URL: https://androidmacro.com/docs/reference/request.md # Request Canonical URL: https://androidmacro.com/docs/reference/request Source file: /docs/reference/request/_category_.json --- Learn the most important android macro concepts. ## Pages - [Request():delete()](https://androidmacro.com/docs/reference/request/delete.md) - [Request():get()](https://androidmacro.com/docs/reference/request/get.md) - [Request():patch()](https://androidmacro.com/docs/reference/request/patch.md) - [Request():post()](https://androidmacro.com/docs/reference/request/post.md) - [Request():put()](https://androidmacro.com/docs/reference/request/put.md) - [Request()](https://androidmacro.com/docs/reference/request/request.md) - [Request():setHeader()](https://androidmacro.com/docs/reference/request/setheader.md) - [Request():setParameter()](https://androidmacro.com/docs/reference/request/setparameter.md) ## Request():delete() Canonical URL: https://androidmacro.com/docs/reference/request/delete Markdown URL: https://androidmacro.com/docs/reference/request/delete.md # Request():delete() Canonical URL: https://androidmacro.com/docs/reference/request/delete Source file: /docs/reference/request/delete.md --- Execute a DELETE request and return a Response object. This method is used to delete a resource from a server. #### Signature ```js delete(): Response ``` **Returns** `Response` - The response object containing the server response ## Description The `delete()` method sends an HTTP DELETE request to the URL specified when creating the Request object. DELETE requests are typically used to remove existing resources from a server, such as deleting a user, post, or any other data entity. ## Examples ### Basic DELETE Request ```js -- Delete a user with ID 123 local response = Request("https://api.example.com/users/123"):delete() ``` ### DELETE Request with Authentication ```js -- Delete a post with authorization local response = Request("https://api.example.com/posts/456") :setHeader("Authorization", "Bearer your-token-here") :setHeader("Accept", "application/json") :delete() ``` ### Processing DELETE Response ```js -- Delete a comment and handle the response local response = Request("https://api.example.com/comments/789") :setHeader("Authorization", "Bearer your-token-here") :delete() local data = response:getData() local statusCode = response:getResponseCode() if statusCode == 204 then print("Comment deleted successfully! (No content)") elseif statusCode == 200 then print("Comment deleted successfully!") print("Response: " .. data) else print("Failed to delete comment. Status: " .. statusCode) end ``` ### DELETE with Additional Headers ```js -- Delete a resource with custom headers local response = Request("https://api.example.com/files/document.pdf") :setHeader("Authorization", "Bearer token123") :setHeader("X-Delete-Reason", "User requested deletion") :setHeader("Accept", "application/json") :delete() local status = response:getResponseCode() if status == 200 or status == 204 then print("File deleted successfully") else print("Delete failed with status: " .. status) end ``` ### Conditional Delete ```js -- Delete only if resource hasn't been modified local response = Request("https://api.example.com/data/123") :setHeader("If-Match", "etag-value-here") :setHeader("Authorization", "Bearer token") :delete() local status = response:getResponseCode() if status == 412 then print("Delete failed: Resource has been modified") elseif status == 200 or status == 204 then print("Resource deleted successfully") end ``` ## Notes - DELETE requests typically don't have a request body - Successful DELETE operations usually return: - `200 OK` with a response body describing the deletion - `202 Accepted` if the deletion is processed asynchronously - `204 No Content` if the deletion was successful with no response body - The method returns a Response object which you can use to access the response data and status code - Always check the response status code to ensure the request was successful - DELETE requests are idempotent - making the same request multiple times should have the same effect (the resource is deleted) - Be careful when using DELETE requests as they permanently remove data ## Request():get() Canonical URL: https://androidmacro.com/docs/reference/request/get Markdown URL: https://androidmacro.com/docs/reference/request/get.md # Request():get() Canonical URL: https://androidmacro.com/docs/reference/request/get Source file: /docs/reference/request/get.md --- Execute a GET request and return a Response object. This method is used to retrieve data from a specified URL. #### Signature ```js get(): Response ``` **Returns** `Response` - The response object containing the server response ## Description The `get()` method sends an HTTP GET request to the URL specified when creating the Request object. GET requests are typically used to retrieve data from a server without modifying any existing data. ## Examples ### Basic GET Request ```js -- Create a GET request to an API endpoint local response = Request("https://api.example.com/users"):get() ``` ### GET Request with Custom Headers ```js -- GET request with authentication header local response = Request("https://api.example.com/protected-data") :setHeader("Authorization", "Bearer your-token-here") :setHeader("Accept", "application/json") :get() ``` ### Processing GET Response ```js -- Make the request and handle the response local response = Request("https://jsonplaceholder.typicode.com/posts/1"):get() -- Get the response data as string local data = response:getData() -- Get the HTTP status code local statusCode = response:getResponseCode() if statusCode == 200 then print("Request successful!") print("Response data: " .. data) else print("Request failed with status: " .. statusCode) end ``` ### GET Request with Query Parameters ```js -- For GET requests with query parameters, include them in the URL local response = Request("https://api.example.com/search?q=lua&limit=10"):get() local results = response:getData() ``` ## Notes - GET requests should not have a request body. If you need to send data, use POST() instead - The method returns a Response object which you can use to access the response data and status code - Always check the response status code to ensure the request was successful - GET requests are idempotent, meaning making the same request multiple times should have the same effect ## Request():patch() Canonical URL: https://androidmacro.com/docs/reference/request/patch Markdown URL: https://androidmacro.com/docs/reference/request/patch.md # Request():patch() Canonical URL: https://androidmacro.com/docs/reference/request/patch Source file: /docs/reference/request/patch.md --- Execute a PATCH request and return a Response object. This method is used to partially update a resource on a server. #### Signature ```js patch(): Response ``` **Returns** `Response` - The response object containing the server response ## Description The `patch()` method sends an HTTP PATCH request to the URL specified when creating the Request object. PATCH requests are typically used to make partial updates to existing resources, modifying only the fields that are provided in the request body. Use `setParameter()` to add data to the request body before calling `patch()`. ## Examples ### Basic PATCH Request ```js -- Update only the email field of a user local response = Request("https://api.example.com/users/123") :setParameter("email", "newemail@example.com") :patch() ``` ### PATCH Request with JSON Headers ```js -- Partially update a post with multiple fields local response = Request("https://api.example.com/posts/456") :setHeader("Content-Type", "application/json") :setHeader("Authorization", "Bearer your-token-here") :setParameter("title", "Updated Post Title") :setParameter("status", "published") :patch() ``` ### Processing PATCH Response ```js -- Update user profile and handle response local response = Request("https://api.example.com/users/789") :setHeader("Content-Type", "application/json") :setHeader("Authorization", "Bearer token123") :setParameter("bio", "Updated bio information") :setParameter("website", "https://mywebsite.com") :patch() local data = response:getData() local statusCode = response:getResponseCode() if statusCode == 200 then print("User updated successfully!") print("Updated data: " .. data) elseif statusCode == 204 then print("User updated successfully! (No content returned)") else print("Failed to update user. Status: " .. statusCode) end ``` ### Conditional PATCH Update ```js -- Update only if resource hasn't been modified local response = Request("https://api.example.com/articles/123") :setHeader("Content-Type", "application/json") :setHeader("If-Match", "etag-value-here") :setHeader("Authorization", "Bearer token") :setParameter("content", "Updated article content") :setParameter("lastModified", "2023-12-01") :patch() local status = response:getResponseCode() if status == 412 then print("Update failed: Resource has been modified by another user") elseif status == 200 or status == 204 then print("Article updated successfully") end ``` ### PATCH with Field Selection ```js -- Update specific fields while leaving others unchanged local response = Request("https://api.example.com/products/456") :setHeader("Content-Type", "application/json") :setParameter("price", "29.99") :setParameter("stock", "150") :setParameter("discount", "10") :patch() local updatedProduct = response:getData() print("Product updated: " .. updatedProduct) ``` ## Notes - Use `setParameter()` to add data to the request body before calling `patch()` - PATCH requests should only contain the fields you want to update, not the entire resource - PATCH is different from PUT in that PATCH performs partial updates, while PUT replaces the entire resource - Successful PATCH operations typically return: - `200 OK` with the updated resource in the response body - `204 No Content` if the update was successful but no response body is needed - The method returns a Response object which you can use to access the response data and status code - Always check the response status code to ensure the request was successful - PATCH requests are not necessarily idempotent - making the same request multiple times may have different effects depending on the implementation ## Request():post() Canonical URL: https://androidmacro.com/docs/reference/request/post Markdown URL: https://androidmacro.com/docs/reference/request/post.md # Request():post() Canonical URL: https://androidmacro.com/docs/reference/request/post Source file: /docs/reference/request/post.md --- Execute a POST request and return a Response object. This method is used to send data to a server, typically to create a new resource. #### Signature ```js post(): Response ``` **Returns** `Response` - The response object containing the server response ## Description The `post()` method sends an HTTP POST request to the URL specified when creating the Request object. POST requests are typically used to submit data to a server for processing, such as creating new records, submitting forms, or uploading data. Use `setParameter()` to add data to the request body before calling `post()`. ## Examples ### Basic POST Request ```js -- Create a POST request with parameters local response = Request("https://api.example.com/users") :setParameter("name", "John Doe") :setParameter("email", "john@example.com") :post() ``` ### POST Request with JSON Headers ```js -- POST request with JSON content type local response = Request("https://api.example.com/posts") :setHeader("Content-Type", "application/json") :setHeader("Authorization", "Bearer your-token-here") :setParameter("title", "My New Post") :setParameter("body", "This is the content of my post") :setParameter("userId", "1") :post() ``` ### Processing POST Response ```js -- Make the POST request and handle the response local response = Request("https://api.example.com/comments") :setHeader("Content-Type", "application/json") :setParameter("postId", "1") :setParameter("name", "Anonymous User") :setParameter("email", "user@example.com") :setParameter("body", "Great article!") :post() -- Get the response data local data = response:getData() local statusCode = response:getResponseCode() if statusCode == 201 then print("Comment created successfully!") print("Response: " .. data) else print("Failed to create comment. Status: " .. statusCode) end ``` ### Form Submission with POST ```js -- Simulate a form submission local response = Request("https://example.com/login") :setHeader("Content-Type", "application/x-www-form-urlencoded") :setParameter("username", "myusername") :setParameter("password", "mypassword") :setParameter("remember", "true") :post() local loginResponse = response:getData() local status = response:getResponseCode() if status == 200 then print("Login successful!") else print("Login failed. Status: " .. status) end ``` ## Notes - Use `setParameter()` to add data to the request body before calling `post()` - POST requests can have a request body containing the data to be sent - The method returns a Response object which you can use to access the response data and status code - For successful resource creation, servers typically return a 201 status code - Always check the response status code to ensure the request was successful - POST requests are not idempotent - making the same request multiple times may create multiple resources ## Request():put() Canonical URL: https://androidmacro.com/docs/reference/request/put Markdown URL: https://androidmacro.com/docs/reference/request/put.md # Request():put() Canonical URL: https://androidmacro.com/docs/reference/request/put Source file: /docs/reference/request/put.md --- Execute a PUT request and return a Response object. This method is used to completely replace a resource on a server. #### Signature ```js put(): Response ``` **Returns** `Response` - The response object containing the server response ## Description The `put()` method sends an HTTP PUT request to the URL specified when creating the Request object. PUT requests are typically used to completely replace existing resources with new data, or to create a resource at a specific URL. Use `setParameter()` to add data to the request body before calling `put()`. ## Examples ### Basic PUT Request ```js -- Replace a user's complete data local response = Request("https://api.example.com/users/123") :setParameter("name", "John Smith") :setParameter("email", "john.smith@example.com") :setParameter("age", "35") :setParameter("status", "active") :put() ``` ### PUT Request with JSON Headers ```js -- Replace an entire post with new content local response = Request("https://api.example.com/posts/456") :setHeader("Content-Type", "application/json") :setHeader("Authorization", "Bearer your-token-here") :setParameter("title", "Completely New Title") :setParameter("body", "Completely new post content") :setParameter("userId", "1") :setParameter("status", "published") :put() ``` ### Processing PUT Response ```js -- Update user profile and handle response local response = Request("https://api.example.com/users/789") :setHeader("Content-Type", "application/json") :setHeader("Authorization", "Bearer token123") :setParameter("name", "Jane Doe") :setParameter("email", "jane.doe@example.com") :setParameter("bio", "Software Developer") :setParameter("website", "https://jane.example.com") :setParameter("location", "San Francisco") :put() local data = response:getData() local statusCode = response:getResponseCode() if statusCode == 200 then print("User updated successfully!") print("Updated user data: " .. data) elseif statusCode == 201 then print("User created successfully!") print("New user data: " .. data) else print("Failed to update user. Status: " .. statusCode) end ``` ### PUT for Resource Creation ```js -- Create a new resource at a specific URL local response = Request("https://api.example.com/files/document-v2") :setHeader("Content-Type", "application/json") :setParameter("content", "This is the new document content") :setParameter("version", "2.0") :setParameter("author", "John Doe") :put() local status = response:getResponseCode() if status == 201 then print("Document created successfully!") elseif status == 200 then print("Document replaced successfully!") else print("Operation failed with status: " .. status) end ``` ### Conditional PUT Update ```js -- Update only if resource hasn't been modified local response = Request("https://api.example.com/articles/123") :setHeader("Content-Type", "application/json") :setHeader("If-Match", "etag-value-here") :setHeader("Authorization", "Bearer token") :setParameter("title", "Updated Article Title") :setParameter("content", "Updated article content") :setParameter("author", "John Doe") :put() local status = response:getResponseCode() if status == 412 then print("Update failed: Resource has been modified by another user") elseif status == 200 or status == 201 then print("Article updated/replaced successfully") end ``` ### Complete Resource Replacement ```js -- Replace an entire product with new data local response = Request("https://api.example.com/products/456") :setHeader("Content-Type", "application/json") :setParameter("name", "Premium Widget") :setParameter("description", "A high-quality widget with advanced features") :setParameter("price", "99.99") :setParameter("stock", "50") :setParameter("category", "electronics") :setParameter("specs", '{"color": "black", "weight": "200g", "warranty": "2 years"}') :put() local updatedProduct = response:getData() print("Product replaced: " .. updatedProduct) ``` ## Notes - Use `setParameter()` to add data to the request body before calling `put()` - PUT requests should contain the complete representation of the resource, not just the changes - PUT is different from PATCH in that PUT replaces the entire resource, while PATCH makes partial updates - Successful PUT operations typically return: - `200 OK` with the updated resource in the response body (for updates) - `201 Created` with the new resource in the response body (for creation) - `204 No Content` if the operation was successful but no response body is needed - The method returns a Response object which you can use to access the response data and status code - Always check the response status code to ensure the request was successful - PUT requests are idempotent - making the same request multiple times should have the same effect - Be careful when using PUT requests as they completely replace existing data ## Request() Canonical URL: https://androidmacro.com/docs/reference/request/request Markdown URL: https://androidmacro.com/docs/reference/request/request.md # Request() Canonical URL: https://androidmacro.com/docs/reference/request/request Source file: /docs/reference/request/request.md --- A module for performing network request to the internet that was introduced on version 1.0.0.31 ## Constructor ```js Request(url: string) ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | --------------------------------- | | url | string | The site url can be https or http | ## Methods ### setHeader(key: string, value: string): Request Set a custom header for the HTTP request. #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------- | | key | string | The header name | | value | string | The header value | #### Returns `Request` - Returns the Request object for method chaining ### setParameter(key: string, value: string): Request Set a parameter for the request body (used with POST/PUT requests). #### Parameters | Parameters | Type | Description | | ---------- | ------ | ------------------- | | key | string | The parameter name | | value | string | The parameter value | #### Returns `Request` - Returns the Request object for method chaining ### get(): Response Execute a GET request and return a Response object. #### Returns `Response` - The response object containing the server response ### post(): Response Execute a POST request and return a Response object. #### Returns `Response` - The response object containing the server response ### put(): Response Execute a PUT request and return a Response object. #### Returns `Response` - The response object containing the server response ### delete(): Response Execute a DELETE request and return a Response object. #### Returns `Response` - The response object containing the server response ## Examples ### Basic GET Request ```js local response = Request("https://api.example.com/data"):get() local data = response:getData() local statusCode = response:getResponseCode() ``` ### POST Request with Headers and Parameters ```js local response = Request("https://api.example.com/users") :setHeader("Content-Type", "application/json") :setHeader("Authorization", "Bearer token123") :setParameter("name", "John Doe") :setParameter("email", "john@example.com") :post() ``` ### Chaining Multiple Methods ```js -- Request objects support method chaining for fluent API local response = Request("https://api.example.com/data") :setHeader("API-Key", "your-api-key") :setParameter("query", "search term") :setParameter("limit", "10") :get() ``` ## Request():setHeader() Canonical URL: https://androidmacro.com/docs/reference/request/setheader Markdown URL: https://androidmacro.com/docs/reference/request/setheader.md # Request():setHeader() Canonical URL: https://androidmacro.com/docs/reference/request/setheader Source file: /docs/reference/request/setheader.md --- Set a new header for HTTP requests. This method allows you to add custom HTTP headers to your request before sending it. #### Signature ```js setHeader(key: string, value: string): Request ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------- | | key | string | The header name | | value | string | The header value | **Returns** `Request` - Returns the Request object for method chaining ## Description The `setHeader()` method adds a custom HTTP header to the request. Headers are metadata that provide additional information about the request, such as content type, authorization, or user agent. You can call this method multiple times to add multiple headers. ## Examples ### Setting Authorization Header ```js -- Add Bearer token for API authentication local response = Request("https://api.example.com/data") :setHeader("Authorization", "Bearer your-token-here") :get() ``` ### Setting Content Type ```js -- Set JSON content type for POST requests local response = Request("https://api.example.com/users") :setHeader("Content-Type", "application/json") :setParameter("name", "John Doe") :setParameter("email", "john@example.com") :post() ``` ### Multiple Headers ```js -- Set multiple headers for a request local response = Request("https://api.example.com/protected") :setHeader("Authorization", "Bearer token123") :setHeader("Content-Type", "application/json") :setHeader("Accept", "application/json") :setHeader("User-Agent", "MyApp/1.0") :get() ``` ### Custom Headers ```js -- Add custom application-specific headers local response = Request("https://api.example.com/process") :setHeader("X-API-Key", "your-api-key") :setHeader("X-Request-ID", "unique-request-identifier") :setHeader("X-Client-Version", "2.1.0") :post() ``` ### Form Data Headers ```js -- Set headers for form data submission local response = Request("https://example.com/login") :setHeader("Content-Type", "application/x-www-form-urlencoded") :setParameter("username", "user") :setParameter("password", "pass") :post() ``` ## Common HTTP Headers | Header Name | Typical Usage | Example | | ---------------- | --------------------------------------------- | -------------------- | | `Authorization` | Authentication tokens | `"Bearer token123"` | | `Content-Type` | Request body format | `"application/json"` | | `Accept` | Response format preference | `"application/json"` | | `User-Agent` | Client identification | `"MyApp/1.0"` | | `X-API-Key` | API authentication | `"your-api-key"` | | `Content-Length` | Request body size (usually set automatically) | `"256"` | ## Notes - Headers are case-insensitive, but it's conventional to use Header-Case (e.g., `Content-Type`) - The method returns the Request object, allowing for method chaining - Some headers may be automatically set by the HTTP client - Certain headers like `Content-Length` are typically calculated automatically - Be careful with authentication headers and don't expose sensitive information - You can override headers by setting the same header name multiple times ## Request():setParameter() Canonical URL: https://androidmacro.com/docs/reference/request/setparameter Markdown URL: https://androidmacro.com/docs/reference/request/setparameter.md # Request():setParameter() Canonical URL: https://androidmacro.com/docs/reference/request/setparameter Source file: /docs/reference/request/setparameter.md --- Set a parameter for the request body (used with POST/PUT/PATCH requests). This method allows you to add data that will be sent in the request body. #### Signature ```js setParameter(key: string, value: string): Request ``` #### Parameters | Parameters | Type | Description | | ---------- | ------ | ------------------- | | key | string | The parameter name | | value | string | The parameter value | **Returns** `Request` - Returns the Request object for method chaining ## Description The `setParameter()` method adds a key-value pair to the request body. This method is primarily used with POST, PUT, and PATCH requests where you need to send data to the server. You can call this method multiple times to add multiple parameters to the request body. ## Examples ### Basic POST with Parameters ```js -- Send form data with POST request local response = Request("https://api.example.com/users") :setParameter("name", "John Doe") :setParameter("email", "john@example.com") :setParameter("age", "30") :post() ``` ### POST Request with JSON Content Type ```js -- Send JSON data with POST request local response = Request("https://api.example.com/posts") :setHeader("Content-Type", "application/json") :setParameter("title", "My New Post") :setParameter("body", "This is the content of my post") :setParameter("userId", "1") :post() ``` ### PUT Request with Parameters ```js -- Update a resource with PUT request local response = Request("https://api.example.com/users/123") :setHeader("Content-Type", "application/json") :setParameter("name", "Jane Smith") :setParameter("email", "jane@example.com") :setParameter("status", "active") :put() ``` ### PATCH Request with Partial Updates ```js -- Partially update a resource with PATCH local response = Request("https://api.example.com/users/456") :setHeader("Content-Type", "application/json") :setParameter("email", "newemail@example.com") :setParameter("lastUpdated", "2023-12-01") :patch() ``` ### Form Submission ```js -- Submit a login form local response = Request("https://example.com/login") :setHeader("Content-Type", "application/x-www-form-urlencoded") :setParameter("username", "myusername") :setParameter("password", "mypassword") :setParameter("remember", "true") :post() ``` ### Search Query with POST ```js -- Send search parameters via POST local response = Request("https://api.example.com/search") :setParameter("query", "lua programming") :setParameter("limit", "10") :setParameter("sort", "relevance") :setParameter("filters", "books,tutorials") :post() local results = response:getData() local status = response:getResponseCode() if status == 200 then print("Search results: " .. results) else print("Search failed with status: " .. status) end ``` ### Complex Data Structure ```js -- Create a complex object with multiple nested parameters local response = Request("https://api.example.com/orders") :setHeader("Content-Type", "application/json") :setParameter("customerId", "12345") :setParameter("productId", "67890") :setParameter("quantity", "2") :setParameter("shippingAddress", "123 Main St, City, State") :setParameter("paymentMethod", "credit_card") :post() ``` ## Parameter Types When using `setParameter()`, all values are treated as strings. Here are common use cases: | Parameter Type | Example | Notes | | -------------- | ----------------------------------------- | ---------------------------------------- | | Text | `setParameter("name", "John Doe")` | Regular text strings | | Numbers | `setParameter("age", "30")` | Numbers should be passed as strings | | Dates | `setParameter("date", "2023-12-01")` | Use ISO format for dates | | Booleans | `setParameter("active", "true")` | Pass "true" or "false" as strings | | JSON | `setParameter("data", '{"key":"value"}')` | JSON strings can be passed as parameters | ## Notes - This method is primarily used with POST, PUT, and PATCH requests - All parameter values are treated as strings - The method returns the Request object, allowing for method chaining - Parameters are typically formatted according to the Content-Type header - For GET requests, parameters should be included in the URL query string instead - The actual format of the request body depends on the Content-Type header set with `setHeader()` - Multiple calls to `setParameter()` with the same key will override previous values ## Response Canonical URL: https://androidmacro.com/docs/reference/response Markdown URL: https://androidmacro.com/docs/reference/response.md # Response Canonical URL: https://androidmacro.com/docs/reference/response Source file: /docs/reference/response/_category_.json --- Response object methods for handling HTTP request results. ## Pages - [Response:getData()](https://androidmacro.com/docs/reference/response/getdata.md) - [Response:getResponseCode()](https://androidmacro.com/docs/reference/response/getresponsecode.md) - [Response](https://androidmacro.com/docs/reference/response/response.md) ## Response:getData() Canonical URL: https://androidmacro.com/docs/reference/response/getdata Markdown URL: https://androidmacro.com/docs/reference/response/getdata.md # Response:getData() Canonical URL: https://androidmacro.com/docs/reference/response/getdata Source file: /docs/reference/response/getdata.md --- Get the response body content as a string from the HTTP response. #### Signature ```js getData(): string ``` **Returns** `string` - The response body content as a string ## Description The `getData()` method retrieves the response body content from an HTTP response. The content is always returned as a string, regardless of the original format (JSON, XML, plain text, HTML, etc.). ## Examples ### Basic Usage ```js -- Make a GET request and get the response data local response = Request("https://api.example.com/users"):get() local userData = response:getData() print("User data: " .. userData) ``` ### Working with JSON Data ```js -- Get JSON response data local response = Request("https://api.example.com/posts/1"):get() local jsonData = response:getData() -- jsonData will be a string like: "{\"id\":1,\"title\":\"Sample Post\",\"body\":\"Content\"}" print("Raw JSON: " .. jsonData) -- Note: You would need a JSON parser to convert this string to a Lua table -- For example (if you have a JSON parser available): -- local parsedData = json.decode(jsonData) -- print("Post title: " .. parsedData.title) ``` ### Handling XML Responses ```js -- Get XML response data local response = Request("https://api.example.com/data.xml"):get() local xmlData = response:getData() -- xmlData will contain XML content as a string if xmlData and xmlData ~= "" then print("XML data received: " .. xmlData) -- You would need an XML parser to process this data end ``` ### Error Response Data ```js -- Make a request that might fail local response = Request("https://api.example.com/invalid"):get() local statusCode = response:getResponseCode() if statusCode ~= 200 then -- Get error details from response body local errorData = response:getData() if errorData and errorData ~= "" then print("Error details: " .. errorData) else print("No error details provided") end end ``` ### POST Request Response Data ```js -- Create a resource and get the response local response = Request("https://api.example.com/users") :setParameter("name", "John Doe") :setParameter("email", "john@example.com") :post() local status = response:getResponseCode() local responseData = response:getData() if status == 201 then print("User created successfully!") print("Created user data: " .. responseData) else print("Failed to create user. Status: " .. status) if responseData then print("Error: " .. responseData) end end ``` ### Empty Response Handling ```js -- Handle responses that might be empty local response = Request("https://api.example.com/delete/123"):delete() local status = response:getResponseCode() local data = response:getData() if status == 204 then -- No content response print("Delete successful (no content returned)") if data == "" or not data then print("Response is empty as expected") end elseif status == 200 then print("Delete successful with response: " .. data) else print("Delete failed with status: " .. status) end ``` ### Processing Different Content Types ```js -- Check Content-Type header if available (this would require accessing response headers) -- For now, we can detect common patterns in the data local response = Request("https://api.example.com/data"):get() local data = response:getData() if data and data ~= "" then -- Detect JSON format if string.sub(data, 1, 1) == "{" or string.sub(data, 1, 1) == "[" then print("Received JSON data") -- Process as JSON -- Detect XML format elseif string.find(data, "^]+>") then print("Received XML data") -- Process as XML -- Detect HTML format elseif string.find(data, "^ 10000 then print("Large response detected - first 100 characters:") print(string.sub(data, 1, 100) .. "...") else print("Complete response:") print(data) end end ``` ## Common Response Content Types | Content Type | Example Data | Usage | | ------------------ | --------------------------------------- | ------------------------------ | | `application/json` | `{"key":"value"}` | REST APIs, modern web services | | `text/plain` | `Simple text response` | Status messages, logs | | `text/html` | `...` | Web pages, error pages | | `application/xml` | `...` | SOAP APIs, XML data | | `text/csv` | `name,age,city\nJohn,30,NYC` | Data export, spreadsheets | ## Notes - Response data is always returned as a string, regardless of the original format - Empty responses return an empty string `""` (common with 204 status codes) - Error responses (4xx, 5xx) may contain useful error information in the response body - Large responses may consume significant memory - consider processing in chunks if needed - You may need additional parsing libraries to work with JSON, XML, or other structured formats - Always check if the response is empty before processing to avoid errors ## Response:getResponseCode() Canonical URL: https://androidmacro.com/docs/reference/response/getresponsecode Markdown URL: https://androidmacro.com/docs/reference/response/getresponsecode.md # Response:getResponseCode() Canonical URL: https://androidmacro.com/docs/reference/response/getresponsecode Source file: /docs/reference/response/getresponsecode.md --- Get the HTTP status code from the response. #### Signature ```js getResponseCode(): number ``` **Returns** `number` - The HTTP status code (e.g., 200, 404, 500) ## Description The `getResponseCode()` method returns the HTTP status code from the server response. Status codes indicate whether the HTTP request was successful, failed, or requires further action. ## Examples ### Basic Status Code Checking ```js -- Make a request and check the status code local response = Request("https://api.example.com/users"):get() local statusCode = response:getResponseCode() if statusCode == 200 then print("Request successful!") local data = response:getData() print("Response data: " .. data) else print("Request failed with status: " .. statusCode) end ``` ### Comprehensive Status Code Handling ```js local response = Request("https://api.example.com/data"):get() local status = response:getResponseCode() if status >= 200 and status = 300 and status = 400 and status = 500 and status = 200 and status = 400 and status = 500 and status = 400 and status = 500 and status < 600 then retries = retries + 1 print("Server error (" .. status .. "), retrying... (" .. retries .. "/" .. maxRetries .. ")") -- Wait before retrying (you might want to add a delay here) else retries = retries + 1 print("Unexpected status (" .. status .. "), retrying... (" .. retries .. "/" .. maxRetries .. ")") end end print("Max retries reached, giving up") return nil end local data = makeRequestWithRetry("https://api.example.com/unstable", 3) if data then print("Request succeeded: " .. data) end ``` ## Common HTTP Status Codes | Code | Category | Meaning | Typical Usage | | ---- | ------------ | --------------------- | ------------------------------ | | 200 | Success | OK | Request successful | | 201 | Success | Created | Resource created | | 204 | Success | No Content | Success, no response body | | 400 | Client Error | Bad Request | Invalid request data | | 401 | Client Error | Unauthorized | Authentication required | | 403 | Client Error | Forbidden | Access denied | | 404 | Client Error | Not Found | Resource doesn't exist | | 409 | Client Error | Conflict | Resource conflict | | 500 | Server Error | Internal Server Error | Server-side error | | 502 | Server Error | Bad Gateway | Invalid upstream response | | 503 | Server Error | Service Unavailable | Server temporarily unavailable | ## Notes - Always check the status code before processing response data - Status codes are standardized across HTTP/1.1 and HTTP/2 - 2xx codes indicate success, 3xx indicate redirection, 4xx indicate client errors, 5xx indicate server errors - Some APIs may use custom status codes or non-standard meanings - Error responses (4xx, 5xx) may contain useful information in the response body - Network errors or timeouts may prevent a response object from being created entirely ## Response Canonical URL: https://androidmacro.com/docs/reference/response/response Markdown URL: https://androidmacro.com/docs/reference/response/response.md # Response Canonical URL: https://androidmacro.com/docs/reference/response/response Source file: /docs/reference/response/response.md --- The Response object contains the result of an HTTP request made with the Request module. It provides access to the response data, status code, and other metadata returned by the server. ## Overview Response objects are returned by HTTP request methods such as `get()`, `post()`, `put()`, `patch()`, and `delete()`. They encapsulate the server's response and provide methods to access the response content and metadata. ## Methods ### getData(): string Get the response body content as a string. #### Returns `string` - The response body content ### getResponseCode(): number Get the HTTP status code from the response. #### Returns `number` - The HTTP status code (e.g., 200, 404, 500) ## Common Usage Pattern ```js -- Make a request and handle the response local response = Request("https://api.example.com/data"):get() -- Get the status code to check if the request was successful local statusCode = response:getResponseCode() if statusCode == 200 then -- Request was successful, get the data local data = response:getData() print("Response data: " .. data) else -- Request failed, handle the error print("Request failed with status: " .. statusCode) local errorData = response:getData() if errorData and errorData ~= "" then print("Error details: " .. errorData) end end ``` ## HTTP Status Code Categories | Status Range | Meaning | Typical Response | | ------------ | ------------ | --------------------------------------- | | 200-299 | Success | Contains requested data or confirmation | | 300-399 | Redirection | Usually empty or contains redirect info | | 400-499 | Client Error | Contains error description | | 500-599 | Server Error | Contains error description | ## Response Data Formats Response data is always returned as a string, regardless of the original format: - **JSON**: `"{\"key\":\"value\"}"` - May need parsing if you have a JSON parser - **XML**: `"..."` - XML content as string - **Plain Text**: `"Simple text response"` - Direct text content - **HTML**: `"..."` - HTML content as string - **Empty**: `""` - No content (common with 204 responses) ## Best Practices 1. **Always check status code first** before processing response data 2. **Handle empty responses** gracefully, especially with 204 status codes 3. **Check response content** even for error responses as they may contain useful information 4. **Be prepared for network errors** that may prevent a response object from being created ## Examples ### Basic Response Handling ```js local response = Request("https://api.example.com/users/123"):get() local status = response:getResponseCode() if status == 200 then local userData = response:getData() print("User data: " .. userData) else print("Failed to get user data. Status: " .. status) end ``` ### Error Handling ```js local response = Request("https://api.example.com/invalid"):get() local status = response:getResponseCode() if status == 404 then print("Resource not found") elseif status == 401 then print("Authentication required") elseif status >= 500 then print("Server error: " .. status) local errorDetails = response:getData() print("Error details: " .. errorDetails) else print("Unexpected status code: " .. status) end ``` ### Working with Different HTTP Methods ```js -- GET request local getResponse = Request("https://api.example.com/data"):get() print("GET status: " .. getResponse:getResponseCode()) -- POST request local postResponse = Request("https://api.example.com/data") :setParameter("key", "value") :post() print("POST status: " .. postResponse:getResponseCode()) -- DELETE request local deleteResponse = Request("https://api.example.com/data/123"):delete() print("DELETE status: " .. deleteResponse:getResponseCode()) ``` ## Row Canonical URL: https://androidmacro.com/docs/reference/row Markdown URL: https://androidmacro.com/docs/reference/row.md # Row Canonical URL: https://androidmacro.com/docs/reference/row Source file: /docs/reference/row/_category_.json --- Learn the most important android macro concepts. ## Pages - [Row():getId()](https://androidmacro.com/docs/reference/row/getid.md) - [Row()](https://androidmacro.com/docs/reference/row/row.md) ## Row():getId() Canonical URL: https://androidmacro.com/docs/reference/row/getid Markdown URL: https://androidmacro.com/docs/reference/row/getid.md # Row():getId() Canonical URL: https://androidmacro.com/docs/reference/row/getid Source file: /docs/reference/row/getid.md --- Will return the id of row view #### Signature ```js getId(): number ``` **Returns** `number` ## Row() Canonical URL: https://androidmacro.com/docs/reference/row/row Markdown URL: https://androidmacro.com/docs/reference/row/row.md # Row() Canonical URL: https://androidmacro.com/docs/reference/row/row Source file: /docs/reference/row/row.md --- Add Row view to dialog ## Constructor ``` Row() ``` ## Screen Canonical URL: https://androidmacro.com/docs/reference/screen Markdown URL: https://androidmacro.com/docs/reference/screen.md # Screen Canonical URL: https://androidmacro.com/docs/reference/screen Source file: /docs/reference/screen/_category_.json --- Learn the most important android macro concepts. ## Pages - [Screen:click()](https://androidmacro.com/docs/reference/screen/click.md) - [Screen:clickAll()](https://androidmacro.com/docs/reference/screen/clickall.md) - [Screen](https://androidmacro.com/docs/reference/screen/constructor.md) - [Screen:exist()](https://androidmacro.com/docs/reference/screen/exist.md) - [Screen:existClick()](https://androidmacro.com/docs/reference/screen/existclick.md) - [Screen:existClickAll()](https://androidmacro.com/docs/reference/screen/existclickall.md) - [Screen:find()](https://androidmacro.com/docs/reference/screen/find.md) - [Screen:findAll()](https://androidmacro.com/docs/reference/screen/findall.md) - [Screen:getColor()](https://androidmacro.com/docs/reference/screen/getcolor.md) - [Screen:getColors()](https://androidmacro.com/docs/reference/screen/getcolors.md) - [Screen:getText()](https://androidmacro.com/docs/reference/screen/gettext.md) - [Screen():getTextMatches()](https://androidmacro.com/docs/reference/screen/gettextmatches.md) - [Screen:getX()](https://androidmacro.com/docs/reference/screen/getx.md) - [Screen:getY()](https://androidmacro.com/docs/reference/screen/gety.md) - [Screen:height()](https://androidmacro.com/docs/reference/screen/height.md) - [Screen:highlight()](https://androidmacro.com/docs/reference/screen/highlight.md) - [Screen:multiSwipe()](https://androidmacro.com/docs/reference/screen/multiswipe.md) - [Screen:screenshot()](https://androidmacro.com/docs/reference/screen/screenshot.md) - [Screen:swipe()](https://androidmacro.com/docs/reference/screen/swipe.md) - [Screen:wait()](https://androidmacro.com/docs/reference/screen/wait.md) - [Screen():waitClick()](https://androidmacro.com/docs/reference/screen/waitclick.md) - [Screen:waitVanish()](https://androidmacro.com/docs/reference/screen/waitvanish.md) - [Screen:width()](https://androidmacro.com/docs/reference/screen/width.md) ## Screen:click() Canonical URL: https://androidmacro.com/docs/reference/screen/click Markdown URL: https://androidmacro.com/docs/reference/screen/click.md # Screen:click() Canonical URL: https://androidmacro.com/docs/reference/screen/click Source file: /docs/reference/screen/click.md --- To perform parameterize click behaviour using `MatchResult` #### Signature ```js Screen:click(match: MatchResult, params: ClickParams): void ``` ```js Screen:click(template: string, params: ClickParams): void ``` ```js Screen:click(point: Point, params: ClickParams): void ``` ```js Screen:click(x: number, y: number, params: ClickParams): void ``` **Returns** `void` ## Screen:clickAll() Canonical URL: https://androidmacro.com/docs/reference/screen/clickall Markdown URL: https://androidmacro.com/docs/reference/screen/clickall.md # Screen:clickAll() Canonical URL: https://androidmacro.com/docs/reference/screen/clickall Source file: /docs/reference/screen/clickall.md --- To perform image/text detection and click it's match coordinate in bulk manner #### Signature ```js Screen:clickAll(template: string, params: ClickParams): void ``` **Returns** `void` ## Screen Canonical URL: https://androidmacro.com/docs/reference/screen/constructor Markdown URL: https://androidmacro.com/docs/reference/screen/constructor.md # Screen Canonical URL: https://androidmacro.com/docs/reference/screen/constructor Source file: /docs/reference/screen/constructor.md --- The module has similar functionality with Region module, except it uses full device width and height ## Screen:exist() Canonical URL: https://androidmacro.com/docs/reference/screen/exist Markdown URL: https://androidmacro.com/docs/reference/screen/exist.md # Screen:exist() Canonical URL: https://androidmacro.com/docs/reference/screen/exist Source file: /docs/reference/screen/exist.md --- To check if match exist in device screen, if match is found then this method returns `true` else `false` #### Signature ```js Screen:exist(template: string): boolean ``` ```js Screen:exist(template: string, params: FinderParams): boolean ``` **Returns** `boolean` ## Screen:existClick() Canonical URL: https://androidmacro.com/docs/reference/screen/existclick Markdown URL: https://androidmacro.com/docs/reference/screen/existclick.md # Screen:existClick() Canonical URL: https://androidmacro.com/docs/reference/screen/existclick Source file: /docs/reference/screen/existclick.md --- To perform image/text detection and click it's match coordinate, if match is found then this method returns `true` #### Signature ```js Screen:existClick(match: MatchResult, params: ClickParams): boolean ``` ```js Screen:existClick(template: string, params: ClickParams): boolean ``` **Returns** `boolean` ## Screen:existClickAll() Canonical URL: https://androidmacro.com/docs/reference/screen/existclickall Markdown URL: https://androidmacro.com/docs/reference/screen/existclickall.md # Screen:existClickAll() Canonical URL: https://androidmacro.com/docs/reference/screen/existclickall Source file: /docs/reference/screen/existclickall.md --- To perform image/text detection and click it's match coordinate, if match is found then this method returns `true` #### Signature ```js Screen:existClickAll(template: string, params: ClickParams): boolean ``` **Returns** `boolean` ## Screen:find() Canonical URL: https://androidmacro.com/docs/reference/screen/find Markdown URL: https://androidmacro.com/docs/reference/screen/find.md # Screen:find() Canonical URL: https://androidmacro.com/docs/reference/screen/find Source file: /docs/reference/screen/find.md --- To perform image or text search in your device screen, if the image or text is found return the `MatchResult` else return `nil` #### Signature ```js Screen:find(template: string): MatchResult | nil ``` ```js Screen:find(template: string, params: FinderParams): MatchResult | nil ``` ```js Screen:find(template: string, timeout: number, params: FinderParams): MatchResult | nil ``` **Returns** `MatchResult` or `nil` ## Screen:findAll() Canonical URL: https://androidmacro.com/docs/reference/screen/findall Markdown URL: https://androidmacro.com/docs/reference/screen/findall.md # Screen:findAll() Canonical URL: https://androidmacro.com/docs/reference/screen/findall Source file: /docs/reference/screen/findall.md --- To perform image or text search in bulk manner and return a list of `MatchResult` #### Signature ```js Screen:findAll(template: string): List ``` ```js Screen:findAll(template: string, params: FinderParams): List ``` **Returns** `List` ## Screen:getColor() Canonical URL: https://androidmacro.com/docs/reference/screen/getcolor Markdown URL: https://androidmacro.com/docs/reference/screen/getcolor.md # Screen:getColor() Canonical URL: https://androidmacro.com/docs/reference/screen/getcolor Source file: /docs/reference/screen/getcolor.md --- To get color pixel in certain coordinate, later this color can be used to compare if color has similar score, this is useful to do color detection #### Signature ```js Screen:getColor(x: number, y: number): Color ``` ```js Screen:getColor(point: Point): Color ``` **Returns** `Color` ## Screen:getColors() Canonical URL: https://androidmacro.com/docs/reference/screen/getcolors Markdown URL: https://androidmacro.com/docs/reference/screen/getcolors.md # Screen:getColors() Canonical URL: https://androidmacro.com/docs/reference/screen/getcolors Source file: /docs/reference/screen/getcolors.md --- To get color pixel in multiple coordinates at the same time, later these colors can be used to compare if color has similar score, this is useful to do color detection #### Signature ```js Screen:getColors(points: List): List ``` **Returns** `List` ## Screen:getText() Canonical URL: https://androidmacro.com/docs/reference/screen/gettext Markdown URL: https://androidmacro.com/docs/reference/screen/gettext.md # Screen:getText() Canonical URL: https://androidmacro.com/docs/reference/screen/gettext Source file: /docs/reference/screen/gettext.md --- This method performs OCR in device screen and return the concatenated text #### Signature ```js Screen:getText(params: FinderParams): string ``` **Returns** `string` ## Screen():getTextMatches() Canonical URL: https://androidmacro.com/docs/reference/screen/gettextmatches Markdown URL: https://androidmacro.com/docs/reference/screen/gettextmatches.md # Screen():getTextMatches() Canonical URL: https://androidmacro.com/docs/reference/screen/gettextmatches Source file: /docs/reference/screen/gettextmatches.md --- Get all text matches found on the screen properly formatted #### Signature ```js getTextMatches(params: FinderParams): Match[] ``` **Returns** `Match[]` ## Screen:getX() Canonical URL: https://androidmacro.com/docs/reference/screen/getx Markdown URL: https://androidmacro.com/docs/reference/screen/getx.md # Screen:getX() Canonical URL: https://androidmacro.com/docs/reference/screen/getx Source file: /docs/reference/screen/getx.md --- Get the x coordinate of screen #### Signature ```js Screen:getX(): number ``` **Returns** `number` ## Screen:getY() Canonical URL: https://androidmacro.com/docs/reference/screen/gety Markdown URL: https://androidmacro.com/docs/reference/screen/gety.md # Screen:getY() Canonical URL: https://androidmacro.com/docs/reference/screen/gety Source file: /docs/reference/screen/gety.md --- Get the y coordinate of screen #### Signature ```js Screen:getY(): number ``` **Returns** `number` ## Screen:height() Canonical URL: https://androidmacro.com/docs/reference/screen/height Markdown URL: https://androidmacro.com/docs/reference/screen/height.md # Screen:height() Canonical URL: https://androidmacro.com/docs/reference/screen/height Source file: /docs/reference/screen/height.md --- Get the height of screen #### Signature ```js Screen:height(): number ``` **Returns** `number` ## Screen:highlight() Canonical URL: https://androidmacro.com/docs/reference/screen/highlight Markdown URL: https://androidmacro.com/docs/reference/screen/highlight.md # Screen:highlight() Canonical URL: https://androidmacro.com/docs/reference/screen/highlight Source file: /docs/reference/screen/highlight.md --- Use for highlighting the screen #### Signature ```js Screen:highlight(secs: number): void ``` **Returns** `void` ## Screen:multiSwipe() Canonical URL: https://androidmacro.com/docs/reference/screen/multiswipe Markdown URL: https://androidmacro.com/docs/reference/screen/multiswipe.md # Screen:multiSwipe() Canonical URL: https://androidmacro.com/docs/reference/screen/multiswipe Source file: /docs/reference/screen/multiswipe.md --- Perform up to 10 fingers swipe simultaneously to the screen. Each finger operates on its own independent timeline — touching down, moving, holding, and lifting according to its own parameters. #### Signature ```js Screen:multiSwipe(fingers: List>): void ``` **Returns** `void` **Compatible Version**: `1.0.0.26` and up ## Parameters | Parameter | Type | Description | | --------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------- | | fingers | `List>` | A list of finger paths. Each finger path is a list of `SwipePoint` values. Minimum 2 points per finger. Maximum 10 fingers. | ## SwipePoint Behavior in multiSwipe Each finger path is a list of `SwipePoint(x, y, holdDuration, swipeDuration)`. The meaning of each parameter depends on the point's position in the list: **First point** (start position): - `swipeDuration` — Initial delay in milliseconds before the finger touches down - `holdDuration` — How long to hold at the start position before moving **Subsequent points** (move targets): - `swipeDuration` — Duration in milliseconds to travel from the previous point to this point - `holdDuration` — How long to hold at this point after arriving **Last point**: - `holdDuration` — Trailing hold at the final position before the finger lifts :::info All fingers lift together after the longest finger's actions complete. ::: ## Examples #### Two-finger swipe up ```js Screen:multiSwipe({ { SwipePoint(500, 800, 50, 0), SwipePoint(500, 400, 50, 1000), }, { SwipePoint(600, 800, 50, 0), SwipePoint(600, 400, 50, 1000), }, }) ``` Both fingers swipe upward simultaneously over 1 second. #### Pinch to zoom ```js Screen:multiSwipe({ { SwipePoint(400, 600, 50, 0), SwipePoint(200, 400, 50, 1500), }, { SwipePoint(600, 600, 50, 0), SwipePoint(800, 800, 50, 1500), }, }) ``` Two fingers move apart from the center over 1.5 seconds. #### Staggered start with hold ```js Screen:multiSwipe({ { SwipePoint(935, 1533, 50, 2000), SwipePoint(658, 1234, 5000, 2000), SwipePoint(207, 1372, 50, 2000), }, { SwipePoint(794, 1714, 50, 3000), SwipePoint(240, 1489, 50, 2000), SwipePoint(694, 1170, 50, 2000), }, }) ``` **Timeline:** | Time | Finger 1 | Finger 2 | | ------- | ------------------------- | ------------------------- | | 0ms | Sleeping (2000ms) | Sleeping (3000ms) | | 2000ms | Press down at (935, 1533) | Sleeping... | | 2050ms | Moving to (658, 1234) | Sleeping... | | 3000ms | Moving... | Press down at (794, 1714) | | 3050ms | Moving... | Moving to (240, 1489) | | 4050ms | Arrive, hold 5000ms | Moving... | | 5050ms | Holding... | Arrive, hold 50ms | | 5100ms | Holding... | Moving to (694, 1170) | | 7100ms | Holding... | Arrive, hold 50ms | | 9050ms | Moving to (207, 1372) | Waiting... | | 11050ms | Arrive, hold 50ms | Waiting... | | 11100ms | All fingers lift together | | ## Limits - Maximum **10 fingers** - Each finger must have at least **2 SwipePoint** values - Total gesture duration must not exceed approximately **60 seconds** - `swipeDuration` of `0` on the first point is treated as `1ms` (essentially instant) ## Screen:screenshot() Canonical URL: https://androidmacro.com/docs/reference/screen/screenshot Markdown URL: https://androidmacro.com/docs/reference/screen/screenshot.md # Screen:screenshot() Canonical URL: https://androidmacro.com/docs/reference/screen/screenshot Source file: /docs/reference/screen/screenshot.md --- Take a screenshot the entire device screen and save it to /data/data/com.androidmacro/images/$macroId/$fileName #### Signature ```js Screen:screenshot(fileName: string): void ``` **Returns** `void` ## Screen:swipe() Canonical URL: https://androidmacro.com/docs/reference/screen/swipe Markdown URL: https://androidmacro.com/docs/reference/screen/swipe.md # Screen:swipe() Canonical URL: https://androidmacro.com/docs/reference/screen/swipe Source file: /docs/reference/screen/swipe.md --- Perform a single-finger swipe on the screen. The swipe path is defined by a list of `SwipePoint` values that the finger moves through sequentially. #### Signature ```js Screen:swipe(swipePoints: List, params?: SwipeParams): void ``` **Returns** `void` ## Parameters | Parameter | Type | Description | | ----------- | ------------------ | -------------------------------------------------------------------- | | swipePoints | `List` | A list of points the finger moves through. Minimum 2 points. | | params | `SwipeParams` | Optional. Controls swipe behavior such as continuous mode and delay. | ## SwipePoint Behavior Each point in the list is a `SwipePoint(x, y, holdDuration, swipeDuration)`. The meaning depends on the point's position: **First point** (start position): - `swipeDuration` — Initial delay in milliseconds before the finger touches down - `holdDuration` — How long to hold at the start position before moving to the next point **Subsequent points** (move targets): - `swipeDuration` — Duration in milliseconds to travel from the previous point to this point - `holdDuration` — How long to hold at this point after arriving (pause before next move) **Last point**: - `holdDuration` — Trailing hold at the final position before the finger lifts ## Examples #### Simple swipe ```js Screen:swipe({ SwipePoint(500, 1200, 50, 0), SwipePoint(500, 400, 50, 1000), }) ``` The finger touches down at (500, 1200) immediately, holds 50ms, then swipes up to (500, 400) over 1 second. #### Swipe with initial delay ```js Screen:swipe({ SwipePoint(300, 800, 50, 2000), SwipePoint(700, 800, 50, 1500), }) ``` Waits 2 seconds, then touches down at (300, 800), holds 50ms, and swipes right to (700, 800) over 1.5 seconds. #### Multi-point swipe with hold ```js Screen:swipe({ SwipePoint(100, 500, 50, 0), SwipePoint(400, 500, 3000, 1000), SwipePoint(400, 900, 50, 1000), }) ``` **Timeline:** | Time | Action | | ------ | ------------------------------------- | | 0ms | Press down at (100, 500) | | 50ms | Start moving to (400, 500) | | 1050ms | Arrive at (400, 500), hold for 3000ms | | 4050ms | Start moving to (400, 900) | | 5050ms | Arrive at (400, 900), hold 50ms | | 5100ms | Finger lifts | The finger swipes right, pauses for 3 seconds, then swipes down. #### Continuous swipe with SwipeParams ```js Screen:swipe({ SwipePoint(200, 600, 50, 0), SwipePoint(500, 300, 50, 2000), }, SwipeParams():setContinue(true)) ``` When `setContinue(true)` is set, the finger does not lift between swipe points. This enables smooth continuous gestures on Android 8.1+ with Accessibility Service. On Native Service, swipes are always continuous regardless of this setting. #### Slow drag ```js Screen:swipe({ SwipePoint(540, 1800, 100, 0), SwipePoint(540, 600, 50, 5000), }) ``` Touches down at (540, 1800), holds 100ms, then slowly drags up to (540, 600) over 5 seconds. ## Screen:wait() Canonical URL: https://androidmacro.com/docs/reference/screen/wait Markdown URL: https://androidmacro.com/docs/reference/screen/wait.md # Screen:wait() Canonical URL: https://androidmacro.com/docs/reference/screen/wait Source file: /docs/reference/screen/wait.md --- Wait until template appear in the screen, if timeout reached this method will throw an error #### Signature ```js Screen:wait(template: string): void ``` ```js Screen:wait(template: string, timeout: number): void ``` ```js Screen:wait(template: string, timeout: number, params: FinderParams): void ``` **Returns** `void` ## Screen():waitClick() Canonical URL: https://androidmacro.com/docs/reference/screen/waitclick Markdown URL: https://androidmacro.com/docs/reference/screen/waitclick.md # Screen():waitClick() Canonical URL: https://androidmacro.com/docs/reference/screen/waitclick Source file: /docs/reference/screen/waitclick.md --- Wait for an image/text to appear on the screen and then click it #### Signature ```js waitClick(template: string, timeout: number, params: ClickParams): void ``` **Returns** `void` ## Screen:waitVanish() Canonical URL: https://androidmacro.com/docs/reference/screen/waitvanish Markdown URL: https://androidmacro.com/docs/reference/screen/waitvanish.md # Screen:waitVanish() Canonical URL: https://androidmacro.com/docs/reference/screen/waitvanish Source file: /docs/reference/screen/waitvanish.md --- Wait until template disappear or vanish in the screen, if timeout reached this method will throw an error #### Signature ```js Screen:waitVanish(template: string): void ``` ```js Screen:waitVanish(template: string, timeout: number): void ``` ```js Screen:waitVanish(template: string, timeout: number, params: FinderParams): void ``` **Returns** `void` ## Screen:width() Canonical URL: https://androidmacro.com/docs/reference/screen/width Markdown URL: https://androidmacro.com/docs/reference/screen/width.md # Screen:width() Canonical URL: https://androidmacro.com/docs/reference/screen/width Source file: /docs/reference/screen/width.md --- Get the width of screen #### Signature ```js Screen:width(): number ``` **Returns** `number` ## Settings Canonical URL: https://androidmacro.com/docs/reference/settings Markdown URL: https://androidmacro.com/docs/reference/settings.md # Settings Canonical URL: https://androidmacro.com/docs/reference/settings Source file: /docs/reference/settings/_category_.json --- Learn the most important android macro concepts. ## Pages - [Settings:cacheOff()](https://androidmacro.com/docs/reference/settings/cacheoff.md) - [Settings:cacheOn()](https://androidmacro.com/docs/reference/settings/cacheon.md) - [Settings:getClickDelay()](https://androidmacro.com/docs/reference/settings/getclickdelay.md) - [Settings:getImagePath()](https://androidmacro.com/docs/reference/settings/getimagepath.md) - [Settings:getMinScore()](https://androidmacro.com/docs/reference/settings/getminscore.md) - [Settings:getScanInterval()](https://androidmacro.com/docs/reference/settings/getscaninterval.md) - [Settings:getSwipeDelay()](https://androidmacro.com/docs/reference/settings/getswipedelay.md) - [Settings:grayscaleOff()](https://androidmacro.com/docs/reference/settings/grayscaleoff.md) - [Settings:grayscaleOn()](https://androidmacro.com/docs/reference/settings/grayscaleon.md) - [Settings:isGrayscale()](https://androidmacro.com/docs/reference/settings/isgrayscale.md) - [Settings:setClickDelay()](https://androidmacro.com/docs/reference/settings/setclickdelay.md) - [Settings:setComparisonHeight()](https://androidmacro.com/docs/reference/settings/setcomparisonheight.md) - [Settings:setComparisonWidth()](https://androidmacro.com/docs/reference/settings/setcomparisonwidth.md) - [Settings:setMinScore()](https://androidmacro.com/docs/reference/settings/setminscore.md) - [Settings:setScanInterval()](https://androidmacro.com/docs/reference/settings/setscaninterval.md) - [Settings:setSwipeDelay()](https://androidmacro.com/docs/reference/settings/setswipedelay.md) - [Settings](https://androidmacro.com/docs/reference/settings/settings.md) ## Settings:cacheOff() Canonical URL: https://androidmacro.com/docs/reference/settings/cacheoff Markdown URL: https://androidmacro.com/docs/reference/settings/cacheoff.md # Settings:cacheOff() Canonical URL: https://androidmacro.com/docs/reference/settings/cacheoff Source file: /docs/reference/settings/cacheoff.md --- When this option is set to off, the macro will not use cache image frame #### Signature ```js Settings:cacheOff(): void ``` **Returns** `void` ## Settings:cacheOn() Canonical URL: https://androidmacro.com/docs/reference/settings/cacheon Markdown URL: https://androidmacro.com/docs/reference/settings/cacheon.md # Settings:cacheOn() Canonical URL: https://androidmacro.com/docs/reference/settings/cacheon Source file: /docs/reference/settings/cacheon.md --- When this option is set to on, the macro will store a temporary cache to store last frame, normally your macro will capture the screen device every time frame is available, this is an intensive operation so in order to prevent that you can use this options #### Signature ```js Settings:cacheOn(): void ``` **Returns** `void` ## Settings:getClickDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/getclickdelay Markdown URL: https://androidmacro.com/docs/reference/settings/getclickdelay.md # Settings:getClickDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/getclickdelay Source file: /docs/reference/settings/getclickdelay.md --- Will return delay of click in currently running macro #### Signature ```js Settings:getClickDelay(): number ``` **Returns** `number` ## Settings:getImagePath() Canonical URL: https://androidmacro.com/docs/reference/settings/getimagepath Markdown URL: https://androidmacro.com/docs/reference/settings/getimagepath.md # Settings:getImagePath() Canonical URL: https://androidmacro.com/docs/reference/settings/getimagepath Source file: /docs/reference/settings/getimagepath.md --- Will return the current path of macro image directory #### Signature ```js Settings:getImagePath(): string ``` **Returns** `string` ## Settings:getMinScore() Canonical URL: https://androidmacro.com/docs/reference/settings/getminscore Markdown URL: https://androidmacro.com/docs/reference/settings/getminscore.md # Settings:getMinScore() Canonical URL: https://androidmacro.com/docs/reference/settings/getminscore Source file: /docs/reference/settings/getminscore.md --- Will return the minimum match score as threshold when you perform text or image detection #### Signature ```js Settings:getMinScore(): number ``` **Returns** `number` ## Settings:getScanInterval() Canonical URL: https://androidmacro.com/docs/reference/settings/getscaninterval Markdown URL: https://androidmacro.com/docs/reference/settings/getscaninterval.md # Settings:getScanInterval() Canonical URL: https://androidmacro.com/docs/reference/settings/getscaninterval Source file: /docs/reference/settings/getscaninterval.md --- Will return the delay of text or image detection in currently running macro #### Signature ```js Settings:getScanInterval(): number ``` **Returns** `number` ## Settings:getSwipeDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/getswipedelay Markdown URL: https://androidmacro.com/docs/reference/settings/getswipedelay.md # Settings:getSwipeDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/getswipedelay Source file: /docs/reference/settings/getswipedelay.md --- Will return delay of swipe in currently running macro #### Signature ```js Settings:getSwipeDelay(): number ``` **Returns** `number` ## Settings:grayscaleOff() Canonical URL: https://androidmacro.com/docs/reference/settings/grayscaleoff Markdown URL: https://androidmacro.com/docs/reference/settings/grayscaleoff.md # Settings:grayscaleOff() Canonical URL: https://androidmacro.com/docs/reference/settings/grayscaleoff Source file: /docs/reference/settings/grayscaleoff.md --- When this option is set to off, the text or image detection will be processed in normal mode #### Signature ```js Settings:grayscaleOff(): void ``` **Returns** `void` ## Settings:grayscaleOn() Canonical URL: https://androidmacro.com/docs/reference/settings/grayscaleon Markdown URL: https://androidmacro.com/docs/reference/settings/grayscaleon.md # Settings:grayscaleOn() Canonical URL: https://androidmacro.com/docs/reference/settings/grayscaleon Source file: /docs/reference/settings/grayscaleon.md --- When this option is set to on, the text or image detection will be processed in grayscale mode, this is useful to speed up the detection process #### Signature ```js Settings:grayscaleOn(): void ``` **Returns** `void` ## Settings:isGrayscale() Canonical URL: https://androidmacro.com/docs/reference/settings/isgrayscale Markdown URL: https://androidmacro.com/docs/reference/settings/isgrayscale.md # Settings:isGrayscale() Canonical URL: https://androidmacro.com/docs/reference/settings/isgrayscale Source file: /docs/reference/settings/isgrayscale.md --- Check if text or image detection is processed in grayscale mode #### Signature ```js Settings:isGrayscale(): boolean ``` **Returns** `boolean` ## Settings:setClickDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/setclickdelay Markdown URL: https://androidmacro.com/docs/reference/settings/setclickdelay.md # Settings:setClickDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/setclickdelay Source file: /docs/reference/settings/setclickdelay.md --- Change the entire click delay in currently running macro #### Signature ```js Settings:setClickDelay(delayMs: number): void ``` **Returns** `void` ## Settings:setComparisonHeight() Canonical URL: https://androidmacro.com/docs/reference/settings/setcomparisonheight Markdown URL: https://androidmacro.com/docs/reference/settings/setcomparisonheight.md # Settings:setComparisonHeight() Canonical URL: https://androidmacro.com/docs/reference/settings/setcomparisonheight Source file: /docs/reference/settings/setcomparisonheight.md --- Change the comparison height, this comparison height is a variable or constant that the Android Macro used to calculate screen resolution between 2 devices with the same aspect ratio #### Signature ```js Settings:setComparisonHeight(height: number): void ``` **Returns** `void` ## Settings:setComparisonWidth() Canonical URL: https://androidmacro.com/docs/reference/settings/setcomparisonwidth Markdown URL: https://androidmacro.com/docs/reference/settings/setcomparisonwidth.md # Settings:setComparisonWidth() Canonical URL: https://androidmacro.com/docs/reference/settings/setcomparisonwidth Source file: /docs/reference/settings/setcomparisonwidth.md --- Change the comparison width, this comparison width is a variable or constant that the Android Macro used to calculate screen resolution between 2 devices with the same aspect ratio #### Signature ```js Settings:setComparisonWidth(width: number): void ``` **Returns** `void` ## Settings:setMinScore() Canonical URL: https://androidmacro.com/docs/reference/settings/setminscore Markdown URL: https://androidmacro.com/docs/reference/settings/setminscore.md # Settings:setMinScore() Canonical URL: https://androidmacro.com/docs/reference/settings/setminscore Source file: /docs/reference/settings/setminscore.md --- Change the minimum threshold score when performing text or image detection #### Signature ```js Settings:setMinScore(score: number): void ``` **Returns** `void` ## Settings:setScanInterval() Canonical URL: https://androidmacro.com/docs/reference/settings/setscaninterval Markdown URL: https://androidmacro.com/docs/reference/settings/setscaninterval.md # Settings:setScanInterval() Canonical URL: https://androidmacro.com/docs/reference/settings/setscaninterval Source file: /docs/reference/settings/setscaninterval.md --- Add delay when you perform text or image detection #### Signature ```js Settings:setScanInterval(interval: number): void ``` **Returns** `void` ## Settings:setSwipeDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/setswipedelay Markdown URL: https://androidmacro.com/docs/reference/settings/setswipedelay.md # Settings:setSwipeDelay() Canonical URL: https://androidmacro.com/docs/reference/settings/setswipedelay Source file: /docs/reference/settings/setswipedelay.md --- Change the entire swipe delay in currently running macro #### Signature ```js Settings:setSwipeDelay(delayMs: number): void ``` **Returns** `void` ## Settings Canonical URL: https://androidmacro.com/docs/reference/settings/settings Markdown URL: https://androidmacro.com/docs/reference/settings/settings.md # Settings Canonical URL: https://androidmacro.com/docs/reference/settings/settings Source file: /docs/reference/settings/settings.md --- Useful to modify macro settings & optimization ## Storage Canonical URL: https://androidmacro.com/docs/reference/storage Markdown URL: https://androidmacro.com/docs/reference/storage.md # Storage Canonical URL: https://androidmacro.com/docs/reference/storage Source file: /docs/reference/storage/_category_.json --- Persistent key-value storage methods for Lua macros. ## Pages - [Storage:append()](https://androidmacro.com/docs/reference/storage/append.md) - [Storage:delete()](https://androidmacro.com/docs/reference/storage/delete.md) - [Storage:read()](https://androidmacro.com/docs/reference/storage/read.md) - [Storage:write()](https://androidmacro.com/docs/reference/storage/write.md) ## Storage:append() Canonical URL: https://androidmacro.com/docs/reference/storage/append Markdown URL: https://androidmacro.com/docs/reference/storage/append.md # Storage:append() Canonical URL: https://androidmacro.com/docs/reference/storage/append Source file: /docs/reference/storage/append.md --- Append data to an existing stored value. #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------------------------- | | key | string | The storage key | | data | any | A `string`, `number`, or `boolean` | #### Signature ```js Storage:append(key: string, data: any): boolean ``` **Returns** `boolean` - `true` when the append request succeeds ## Examples ```js Storage:write("log", "start") Storage:append("log", "|next-step") ``` ```js local ok = Storage:append("counter", 1) print(ok) ``` ## Notes - If the key does not exist, the backend may create it with the appended value - The current implementation accepts only simple values - Network and authentication errors are raised as exceptions ## Storage:delete() Canonical URL: https://androidmacro.com/docs/reference/storage/delete Markdown URL: https://androidmacro.com/docs/reference/storage/delete.md # Storage:delete() Canonical URL: https://androidmacro.com/docs/reference/storage/delete Source file: /docs/reference/storage/delete.md --- Delete a stored value by key. #### Parameters | Parameters | Type | Description | | ---------- | ------ | --------------- | | key | string | The storage key | #### Signature ```js Storage:delete(key: string): boolean ``` **Returns** `boolean` - `true` when the key is deleted successfully ## Examples ```js local ok = Storage:delete("session_token") print(ok) ``` ```js Storage:write("temp_key", "value") Storage:delete("temp_key") ``` ## Notes - Deleting a missing key raises an error in the current implementation - The key must not be empty ## Storage:read() Canonical URL: https://androidmacro.com/docs/reference/storage/read Markdown URL: https://androidmacro.com/docs/reference/storage/read.md # Storage:read() Canonical URL: https://androidmacro.com/docs/reference/storage/read Source file: /docs/reference/storage/read.md --- Read a stored value by key. #### Parameters | Parameters | Type | Description | | ---------- | ------ | --------------- | | key | string | The storage key | #### Signature ```js Storage:read(key: string): string | nil ``` **Returns** `string | nil` - The stored value as a string, or `nil` when the key is not found ## Description `Storage:read()` returns the stored value as text. Numeric and boolean values are also returned as strings. ## Examples ```js local username = Storage:read("username") if username ~= nil then print(username) end ``` ```js local retryCount = Storage:read("retry_count") if retryCount ~= nil then local count = tonumber(retryCount) print(count) end ``` ## Notes - Missing keys return `nil` - Stored numbers and booleans are returned as strings - The key must not be empty ## Storage:write() Canonical URL: https://androidmacro.com/docs/reference/storage/write Markdown URL: https://androidmacro.com/docs/reference/storage/write.md # Storage:write() Canonical URL: https://androidmacro.com/docs/reference/storage/write Source file: /docs/reference/storage/write.md --- Store a value using a string key. #### Parameters | Parameters | Type | Description | | ---------- | ------ | ---------------------------------- | | key | string | The storage key | | data | any | A `string`, `number`, or `boolean` | #### Signature ```js Storage:write(key: string, data: any): boolean ``` **Returns** `boolean` - `true` when the value is stored successfully ## Examples ```js local ok = Storage:write("email", "sample.user@example.com") print(ok) ``` ```js Storage:write("retry_count", 3) Storage:write("is_premium", true) ``` ## Notes - The key must not be empty - The current implementation rejects Lua tables and other complex values - On request failure, this method throws an error instead of returning `false` ## SwipeParams Canonical URL: https://androidmacro.com/docs/reference/swipe-params Markdown URL: https://androidmacro.com/docs/reference/swipe-params.md # SwipeParams Canonical URL: https://androidmacro.com/docs/reference/swipe-params Source file: /docs/reference/swipe-params/_category_.json --- Learn the most important android macro concepts. ## Pages - [SwipeParams():getDelay()](https://androidmacro.com/docs/reference/swipe-params/getdelay.md) - [SwipeParams():isContinue()](https://androidmacro.com/docs/reference/swipe-params/iscontinue.md) - [SwipeParams():setContinue()](https://androidmacro.com/docs/reference/swipe-params/setcontinue.md) - [SwipeParams():setDelay()](https://androidmacro.com/docs/reference/swipe-params/setdelay.md) - [SwipeParams()](https://androidmacro.com/docs/reference/swipe-params/swipe-params.md) ## SwipeParams():getDelay() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/getdelay Markdown URL: https://androidmacro.com/docs/reference/swipe-params/getdelay.md # SwipeParams():getDelay() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/getdelay Source file: /docs/reference/swipe-params/getdelay.md --- Will return the delay of each swipe points #### Signature ```js getDelay(): number ``` **Returns** `number` ## SwipeParams():isContinue() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/iscontinue Markdown URL: https://androidmacro.com/docs/reference/swipe-params/iscontinue.md # SwipeParams():isContinue() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/iscontinue Source file: /docs/reference/swipe-params/iscontinue.md --- Return true if swipe points are continuous #### Signature ```js isContinue(): boolean ``` **Returns** `boolean` ## SwipeParams():setContinue() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/setcontinue Markdown URL: https://androidmacro.com/docs/reference/swipe-params/setcontinue.md # SwipeParams():setContinue() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/setcontinue Source file: /docs/reference/swipe-params/setcontinue.md --- You can set whether each swipe point is continuous, which means the swiping finger does not lift up. This behavior works as intended on Android 8.1 and higher with Accessibility Service. If you are using an Android version lower than 8.1, this method will not make your swipes continuous due to Android limitations for Accessibility Service. However, if you use the Native Service, you are not affected by this limitation. #### Signature ```js setContinue(continue: boolean): SwipeParams ``` **Returns** `SwipeParams` ## SwipeParams():setDelay() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/setdelay Markdown URL: https://androidmacro.com/docs/reference/swipe-params/setdelay.md # SwipeParams():setDelay() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/setdelay Source file: /docs/reference/swipe-params/setdelay.md --- You can set swipe delay in milliseconds using this method #### Signature ```js setDelay(): SwipeParams ``` **Returns** `SwipeParams` ## SwipeParams() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/swipe-params Markdown URL: https://androidmacro.com/docs/reference/swipe-params/swipe-params.md # SwipeParams() Canonical URL: https://androidmacro.com/docs/reference/swipe-params/swipe-params Source file: /docs/reference/swipe-params/swipe-params.md --- Useful to parameterize swipe events ## Constructor ``` SwipeParams() ``` This class will initialize default parameter for swipe events ## SwipePoint Canonical URL: https://androidmacro.com/docs/reference/swipepoint Markdown URL: https://androidmacro.com/docs/reference/swipepoint.md # SwipePoint Canonical URL: https://androidmacro.com/docs/reference/swipepoint Source file: /docs/reference/swipepoint/_category_.json --- Learn the most important android macro concepts. ## Pages - [SwipePoint():getHoldDuration()](https://androidmacro.com/docs/reference/swipepoint/getholdduration.md) - [SwipePoint():getSpeed() [DEPRECATED]](https://androidmacro.com/docs/reference/swipepoint/getspeed.md) - [SwipePoint():getSwipeDuration()](https://androidmacro.com/docs/reference/swipepoint/getswipeduration.md) - [SwipePoint():getX()](https://androidmacro.com/docs/reference/swipepoint/getx.md) - [SwipePoint():getY()](https://androidmacro.com/docs/reference/swipepoint/gety.md) - [SwipePoint():setHoldDuration()](https://androidmacro.com/docs/reference/swipepoint/setholdduration.md) - [SwipePoint():setSpeed() [DEPRECATED]](https://androidmacro.com/docs/reference/swipepoint/setspeed.md) - [SwipePoint():setSwipeDuration()](https://androidmacro.com/docs/reference/swipepoint/setswipeduration.md) - [SwipePoint():setX()](https://androidmacro.com/docs/reference/swipepoint/setx.md) - [SwipePoint():setY()](https://androidmacro.com/docs/reference/swipepoint/sety.md) - [SwipePoint()](https://androidmacro.com/docs/reference/swipepoint/swipepoint.md) ## SwipePoint():getHoldDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getholdduration Markdown URL: https://androidmacro.com/docs/reference/swipepoint/getholdduration.md # SwipePoint():getHoldDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getholdduration Source file: /docs/reference/swipepoint/getholdduration.md --- Will return swipe point hold duration #### Signature ```js getHoldDuration(): number ``` **Returns** `number` ## SwipePoint():getSpeed() [DEPRECATED] Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getspeed Markdown URL: https://androidmacro.com/docs/reference/swipepoint/getspeed.md # SwipePoint():getSpeed() [DEPRECATED] Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getspeed Source file: /docs/reference/swipepoint/getspeed.md --- Will return swipe point speed. This method won't work after version 1.0.0.16 #### Signature ```js getSpeed(): number ``` **Returns** `number` ## SwipePoint():getSwipeDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getswipeduration Markdown URL: https://androidmacro.com/docs/reference/swipepoint/getswipeduration.md # SwipePoint():getSwipeDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getswipeduration Source file: /docs/reference/swipepoint/getswipeduration.md --- Will return swipe point duration #### Signature ```js getSwipeDuration(): number ``` **Returns** `number` ## SwipePoint():getX() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getx Markdown URL: https://androidmacro.com/docs/reference/swipepoint/getx.md # SwipePoint():getX() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/getx Source file: /docs/reference/swipepoint/getx.md --- Will return swipe point x coordinate #### Signature ```js getX(): number ``` **Returns** `number` ## SwipePoint():getY() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/gety Markdown URL: https://androidmacro.com/docs/reference/swipepoint/gety.md # SwipePoint():getY() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/gety Source file: /docs/reference/swipepoint/gety.md --- Will return swipe point y coordinate #### Signature ```js getY(): number ``` **Returns** `number` ## SwipePoint():setHoldDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setholdduration Markdown URL: https://androidmacro.com/docs/reference/swipepoint/setholdduration.md # SwipePoint():setHoldDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setholdduration Source file: /docs/reference/swipepoint/setholdduration.md --- Change the hold duration of swipe point #### Signature ```js setHoldDuration(duration: number): void ``` **Returns** `void` ## SwipePoint():setSpeed() [DEPRECATED] Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setspeed Markdown URL: https://androidmacro.com/docs/reference/swipepoint/setspeed.md # SwipePoint():setSpeed() [DEPRECATED] Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setspeed Source file: /docs/reference/swipepoint/setspeed.md --- Change the speed of swipe point. This method won't work after version 1.0.0.16 #### Signature ```js setSpeed(speed: number): void ``` **Returns** `void` ## SwipePoint():setSwipeDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setswipeduration Markdown URL: https://androidmacro.com/docs/reference/swipepoint/setswipeduration.md # SwipePoint():setSwipeDuration() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setswipeduration Source file: /docs/reference/swipepoint/setswipeduration.md --- Change the duration of swipe point #### Signature ```js setSwipeDuration(duration: number): void ``` **Returns** `void` ## SwipePoint():setX() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setx Markdown URL: https://androidmacro.com/docs/reference/swipepoint/setx.md # SwipePoint():setX() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/setx Source file: /docs/reference/swipepoint/setx.md --- Change the x coordinate of swipe point #### Signature ```js setX(x: number): void ``` **Returns** `void` ## SwipePoint():setY() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/sety Markdown URL: https://androidmacro.com/docs/reference/swipepoint/sety.md # SwipePoint():setY() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/sety Source file: /docs/reference/swipepoint/sety.md --- Change the y coordinate of swipe point #### Signature ```js setY(y: number): void ``` **Returns** `void` ## SwipePoint() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/swipepoint Markdown URL: https://androidmacro.com/docs/reference/swipepoint/swipepoint.md # SwipePoint() Canonical URL: https://androidmacro.com/docs/reference/swipepoint/swipepoint Source file: /docs/reference/swipepoint/swipepoint.md --- Represents a point in a swipe path. Used with [`Screen:swipe()`](/docs/reference/screen/swipe) and [`Screen:multiSwipe()`](/docs/reference/screen/multiswipe) to define where the finger moves, how fast, and how long it pauses. ## Constructor ```js SwipePoint(x, y, holdDuration, swipeDuration); ``` #### Parameters | Parameter | Type | Default | Description | | ------------- | ------ | -------- | ------------------------------------------------------------------------ | | x | number | required | The x coordinate in screen pixels | | y | number | required | The y coordinate in screen pixels | | holdDuration | number | `50` | How long in milliseconds to hold at this position | | swipeDuration | number | `2000` | Duration in milliseconds (meaning depends on position in the swipe list) | #### Parameter meaning depends on position The `swipeDuration` and `holdDuration` parameters have different meanings depending on whether the SwipePoint is the **first point** or a **subsequent point** in the swipe list: **As the first point:** - `swipeDuration` — Initial delay before the finger touches down (sleep) - `holdDuration` — Hold at the start position before moving **As a subsequent point:** - `swipeDuration` — Duration to travel from the previous point to this point - `holdDuration` — Hold at this point after arriving ## Example ```js -- Touch down at (500, 1000) after 1 second delay, -- hold 50ms, then move to (500, 400) over 2 seconds Screen:swipe({ SwipePoint(500, 1000, 50, 1000), SwipePoint(500, 400, 50, 2000), }) ``` ## Notes - If `swipeDuration` is `0`, it is treated as `1` ms (essentially instant) - If `holdDuration` is `0`, there is no hold at that point ## System Canonical URL: https://androidmacro.com/docs/reference/system Markdown URL: https://androidmacro.com/docs/reference/system.md # System Canonical URL: https://androidmacro.com/docs/reference/system Source file: /docs/reference/system/_category_.json --- Learn the most important android macro concepts. ## Pages - [System:back()](https://androidmacro.com/docs/reference/system/back.md) - [System:home()](https://androidmacro.com/docs/reference/system/home.md) - [System:recent()](https://androidmacro.com/docs/reference/system/recent.md) - [System:spawn()](https://androidmacro.com/docs/reference/system/spawn.md) - [System](https://androidmacro.com/docs/reference/system/system.md) ## System:back() Canonical URL: https://androidmacro.com/docs/reference/system/back Markdown URL: https://androidmacro.com/docs/reference/system/back.md # System:back() Canonical URL: https://androidmacro.com/docs/reference/system/back Source file: /docs/reference/system/back.md --- Press back button #### Signature ```js System:back(): void ``` **Returns** `void` ## System:home() Canonical URL: https://androidmacro.com/docs/reference/system/home Markdown URL: https://androidmacro.com/docs/reference/system/home.md # System:home() Canonical URL: https://androidmacro.com/docs/reference/system/home Source file: /docs/reference/system/home.md --- Press home button #### Signature ```js System:home(): void ``` **Returns** `void` ## System:recent() Canonical URL: https://androidmacro.com/docs/reference/system/recent Markdown URL: https://androidmacro.com/docs/reference/system/recent.md # System:recent() Canonical URL: https://androidmacro.com/docs/reference/system/recent Source file: /docs/reference/system/recent.md --- Press recent button #### Signature ```js System:recent(): void ``` **Returns** `void` ## System:spawn() Canonical URL: https://androidmacro.com/docs/reference/system/spawn Markdown URL: https://androidmacro.com/docs/reference/system/spawn.md # System:spawn() Canonical URL: https://androidmacro.com/docs/reference/system/spawn Source file: /docs/reference/system/spawn.md --- Press recent button #### Parameters | Parameters | Type | Description | | ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------- | | package | string | The package name of the app you want to open | | activity | string | If you are using android 11+ you need to specify the activity of the target app, due to restriction that is implemented in android 11+ | #### Signature ```js System:recent(package: string): void ``` ```js System:recent(package: string, activity: string): void ``` **Returns** `void` ## System Canonical URL: https://androidmacro.com/docs/reference/system/system Markdown URL: https://androidmacro.com/docs/reference/system/system.md # System Canonical URL: https://androidmacro.com/docs/reference/system/system Source file: /docs/reference/system/system.md --- Utility class to press system button ## TextView Canonical URL: https://androidmacro.com/docs/reference/textview Markdown URL: https://androidmacro.com/docs/reference/textview.md # TextView Canonical URL: https://androidmacro.com/docs/reference/textview Source file: /docs/reference/textview/_category_.json --- Learn the most important android macro concepts. ## Pages - [TextView():getText()](https://androidmacro.com/docs/reference/textview/gettext.md) - [TextView()](https://androidmacro.com/docs/reference/textview/textview.md) ## TextView():getText() Canonical URL: https://androidmacro.com/docs/reference/textview/gettext Markdown URL: https://androidmacro.com/docs/reference/textview/gettext.md # TextView():getText() Canonical URL: https://androidmacro.com/docs/reference/textview/gettext Source file: /docs/reference/textview/gettext.md --- Get text content #### Signature ```js getText(): string ``` **Returns** `string` ## TextView() Canonical URL: https://androidmacro.com/docs/reference/textview/textview Markdown URL: https://androidmacro.com/docs/reference/textview/textview.md # TextView() Canonical URL: https://androidmacro.com/docs/reference/textview/textview Source file: /docs/reference/textview/textview.md --- Add TextView to the dialog view ## Constructor ``` TextView(text: string) ``` #### Parameters | Parameters | Type | Description | | ---------- | -------- | --------------------- | | text | `string` | text of the text view | ## ToastParams Canonical URL: https://androidmacro.com/docs/reference/toast-params Markdown URL: https://androidmacro.com/docs/reference/toast-params.md # ToastParams Canonical URL: https://androidmacro.com/docs/reference/toast-params Source file: /docs/reference/toast-params/_category_.json --- Learn the most important android macro concepts. ## Pages - [ToastParams():getDuration()](https://androidmacro.com/docs/reference/toast-params/getduration.md) - [ToastParams():getOpacity()](https://androidmacro.com/docs/reference/toast-params/getopacity.md) - [ToastParams():getPadding()](https://androidmacro.com/docs/reference/toast-params/getpadding.md) - [ToastParams():getPosition()](https://androidmacro.com/docs/reference/toast-params/getposition.md) - [ToastParams():getRadius()](https://androidmacro.com/docs/reference/toast-params/getradius.md) - [ToastParams():getTextColor()](https://androidmacro.com/docs/reference/toast-params/gettextcolor.md) - [ToastParams():setDuration()](https://androidmacro.com/docs/reference/toast-params/setduration.md) - [ToastParams():setOpacity()](https://androidmacro.com/docs/reference/toast-params/setopacity.md) - [ToastParams():setPadding()](https://androidmacro.com/docs/reference/toast-params/setpadding.md) - [ToastParams():setPosition()](https://androidmacro.com/docs/reference/toast-params/setposition.md) - [ToastParams():setRadius()](https://androidmacro.com/docs/reference/toast-params/setradius.md) - [ToastParams():setTextColor()](https://androidmacro.com/docs/reference/toast-params/settextcolor.md) - [ToastParams()](https://androidmacro.com/docs/reference/toast-params/toast-params.md) ## ToastParams():getDuration() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getduration Markdown URL: https://androidmacro.com/docs/reference/toast-params/getduration.md # ToastParams():getDuration() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getduration Source file: /docs/reference/toast-params/getduration.md --- Will return the duration of the toast #### Signature ```js getDuration(): number ``` **Returns** `number` ## ToastParams():getOpacity() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getopacity Markdown URL: https://androidmacro.com/docs/reference/toast-params/getopacity.md # ToastParams():getOpacity() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getopacity Source file: /docs/reference/toast-params/getopacity.md --- Will return the current opacity level #### Signature ```js getOpacity(): number ``` **Returns** `number` ## ToastParams():getPadding() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getpadding Markdown URL: https://androidmacro.com/docs/reference/toast-params/getpadding.md # ToastParams():getPadding() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getpadding Source file: /docs/reference/toast-params/getpadding.md --- Will return the current padding as an array of numbers `[left, top, right, bottom]` #### Signature ```js getPadding(): number[] ``` **Returns** `number[]` ## ToastParams():getPosition() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getposition Markdown URL: https://androidmacro.com/docs/reference/toast-params/getposition.md # ToastParams():getPosition() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getposition Source file: /docs/reference/toast-params/getposition.md --- Will return the current position of the toast as a Point object #### Signature ```js getPosition(): Point ``` **Returns** `Point` ## ToastParams():getRadius() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getradius Markdown URL: https://androidmacro.com/docs/reference/toast-params/getradius.md # ToastParams():getRadius() Canonical URL: https://androidmacro.com/docs/reference/toast-params/getradius Source file: /docs/reference/toast-params/getradius.md --- Will return the current corner radius #### Signature ```js getRadius(): number ``` **Returns** `number` ## ToastParams():getTextColor() Canonical URL: https://androidmacro.com/docs/reference/toast-params/gettextcolor Markdown URL: https://androidmacro.com/docs/reference/toast-params/gettextcolor.md # ToastParams():getTextColor() Canonical URL: https://androidmacro.com/docs/reference/toast-params/gettextcolor Source file: /docs/reference/toast-params/gettextcolor.md --- Will return the current text color string #### Signature ```js getTextColor(): string ``` **Returns** `string` ## ToastParams():setDuration() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setduration Markdown URL: https://androidmacro.com/docs/reference/toast-params/setduration.md # ToastParams():setDuration() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setduration Source file: /docs/reference/toast-params/setduration.md --- You can set how long the toast is visible in milliseconds #### Signature ```js setDuration(ms: number): ToastParams ``` **Returns** `ToastParams` ## ToastParams():setOpacity() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setopacity Markdown URL: https://androidmacro.com/docs/reference/toast-params/setopacity.md # ToastParams():setOpacity() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setopacity Source file: /docs/reference/toast-params/setopacity.md --- You can set the transparency level of the toast using this method (0.0 to 1.0) #### Signature ```js setOpacity(opacity: number): ToastParams ``` **Returns** `ToastParams` ## ToastParams():setPadding() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setpadding Markdown URL: https://androidmacro.com/docs/reference/toast-params/setpadding.md # ToastParams():setPadding() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setpadding Source file: /docs/reference/toast-params/setpadding.md --- You can set custom padding for the toast content #### Signature ```js setPadding(left: number, top: number, right: number, bottom: number): ToastParams ``` **Returns** `ToastParams` ## ToastParams():setPosition() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setposition Markdown URL: https://androidmacro.com/docs/reference/toast-params/setposition.md # ToastParams():setPosition() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setposition Source file: /docs/reference/toast-params/setposition.md --- You can set the position of the toast on the screen using x and y coordinates #### Signature ```js setPosition(x: number, y: number): ToastParams ``` **Returns** `ToastParams` ## ToastParams():setRadius() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setradius Markdown URL: https://androidmacro.com/docs/reference/toast-params/setradius.md # ToastParams():setRadius() Canonical URL: https://androidmacro.com/docs/reference/toast-params/setradius Source file: /docs/reference/toast-params/setradius.md --- You can set the corner radius of the toast background #### Signature ```js setRadius(radius: number): ToastParams ``` **Returns** `ToastParams` ## ToastParams():setTextColor() Canonical URL: https://androidmacro.com/docs/reference/toast-params/settextcolor Markdown URL: https://androidmacro.com/docs/reference/toast-params/settextcolor.md # ToastParams():setTextColor() Canonical URL: https://androidmacro.com/docs/reference/toast-params/settextcolor Source file: /docs/reference/toast-params/settextcolor.md --- You can set the text color of the toast (e.g., "#FF0000" or "#AARRGGBB") #### Signature ```js setTextColor(color: string): ToastParams ``` **Returns** `ToastParams` ## ToastParams() Canonical URL: https://androidmacro.com/docs/reference/toast-params/toast-params Markdown URL: https://androidmacro.com/docs/reference/toast-params/toast-params.md # ToastParams() Canonical URL: https://androidmacro.com/docs/reference/toast-params/toast-params Source file: /docs/reference/toast-params/toast-params.md --- Useful to parameterize toast messages ## Constructor ```js ToastParams() ``` This class will initialize default parameter for toast messages ## Toolbar Canonical URL: https://androidmacro.com/docs/reference/toolbar Markdown URL: https://androidmacro.com/docs/reference/toolbar.md # Toolbar Canonical URL: https://androidmacro.com/docs/reference/toolbar Source file: /docs/reference/toolbar/_category_.json --- Toolbar service controls for showing, hiding, moving, and styling the floating toolbar. ## Pages - [Toolbar:getOpacity()](https://androidmacro.com/docs/reference/toolbar/getopacity.md) - [Toolbar:getScale()](https://androidmacro.com/docs/reference/toolbar/getscale.md) - [Toolbar:hide()](https://androidmacro.com/docs/reference/toolbar/hide.md) - [Toolbar:isAvailable()](https://androidmacro.com/docs/reference/toolbar/isavailable.md) - [Toolbar:isSnapped()](https://androidmacro.com/docs/reference/toolbar/issnapped.md) - [Toolbar:isVisible()](https://androidmacro.com/docs/reference/toolbar/isvisible.md) - [Toolbar:setCollapse()](https://androidmacro.com/docs/reference/toolbar/setcollapse.md) - [Toolbar:setOpacity()](https://androidmacro.com/docs/reference/toolbar/setopacity.md) - [Toolbar:setPosition()](https://androidmacro.com/docs/reference/toolbar/setposition.md) - [Toolbar:setScale()](https://androidmacro.com/docs/reference/toolbar/setscale.md) - [Toolbar:setSnap()](https://androidmacro.com/docs/reference/toolbar/setsnap.md) - [Toolbar:show()](https://androidmacro.com/docs/reference/toolbar/show.md) - [Toolbar](https://androidmacro.com/docs/reference/toolbar/toolbar.md) ## Toolbar:getOpacity() Canonical URL: https://androidmacro.com/docs/reference/toolbar/getopacity Markdown URL: https://androidmacro.com/docs/reference/toolbar/getopacity.md # Toolbar:getOpacity() Canonical URL: https://androidmacro.com/docs/reference/toolbar/getopacity Source file: /docs/reference/toolbar/getopacity.md --- Get the current toolbar opacity. #### Signature ```js Toolbar:getOpacity(): number ``` **Returns** `number` - The current toolbar opacity ## Example ```js local opacity = Toolbar:getOpacity() print(opacity) ``` ## Toolbar:getScale() Canonical URL: https://androidmacro.com/docs/reference/toolbar/getscale Markdown URL: https://androidmacro.com/docs/reference/toolbar/getscale.md # Toolbar:getScale() Canonical URL: https://androidmacro.com/docs/reference/toolbar/getscale Source file: /docs/reference/toolbar/getscale.md --- Get the current toolbar scale factor. #### Signature ```js Toolbar:getScale(): number ``` **Returns** `number` - The current toolbar scale ## Example ```js local scale = Toolbar:getScale() print(scale) ``` ## Toolbar:hide() Canonical URL: https://androidmacro.com/docs/reference/toolbar/hide Markdown URL: https://androidmacro.com/docs/reference/toolbar/hide.md # Toolbar:hide() Canonical URL: https://androidmacro.com/docs/reference/toolbar/hide Source file: /docs/reference/toolbar/hide.md --- Hide the floating toolbar. #### Signature ```js Toolbar:hide(): void ``` **Returns** `void` ## Example ```js if Toolbar:isAvailable() then Toolbar:hide() end ``` ## Toolbar:isAvailable() Canonical URL: https://androidmacro.com/docs/reference/toolbar/isavailable Markdown URL: https://androidmacro.com/docs/reference/toolbar/isavailable.md # Toolbar:isAvailable() Canonical URL: https://androidmacro.com/docs/reference/toolbar/isavailable Source file: /docs/reference/toolbar/isavailable.md --- Check whether the floating toolbar service is available. #### Signature ```js Toolbar:isAvailable(): boolean ``` **Returns** `boolean` - `true` when the toolbar service is running and the toolbar view exists ## Examples ```js if Toolbar:isAvailable() then print("Toolbar is ready") end ``` ## Toolbar:isSnapped() Canonical URL: https://androidmacro.com/docs/reference/toolbar/issnapped Markdown URL: https://androidmacro.com/docs/reference/toolbar/issnapped.md # Toolbar:isSnapped() Canonical URL: https://androidmacro.com/docs/reference/toolbar/issnapped Source file: /docs/reference/toolbar/issnapped.md --- Check whether the toolbar is currently in a snapped state. #### Signature ```js Toolbar:isSnapped(): boolean ``` **Returns** `boolean` - `true` when the toolbar is snapped or collapsed ## Example ```js if Toolbar:isSnapped() then Toolbar:setSnap(false) end ``` ## Toolbar:isVisible() Canonical URL: https://androidmacro.com/docs/reference/toolbar/isvisible Markdown URL: https://androidmacro.com/docs/reference/toolbar/isvisible.md # Toolbar:isVisible() Canonical URL: https://androidmacro.com/docs/reference/toolbar/isvisible Source file: /docs/reference/toolbar/isvisible.md --- Check whether the toolbar is currently visible on screen. #### Signature ```js Toolbar:isVisible(): boolean ``` **Returns** `boolean` - `true` when the toolbar is visible ## Notes - This method throws an error if the toolbar service is not running ## Toolbar:setCollapse() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setcollapse Markdown URL: https://androidmacro.com/docs/reference/toolbar/setcollapse.md # Toolbar:setCollapse() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setcollapse Source file: /docs/reference/toolbar/setcollapse.md --- Enable or disable collapsed circle mode for the toolbar. #### Parameters | Parameters | Type | Description | | ---------- | ------- | -------------------------------------- | | collapsed | boolean | `true` to collapse, `false` to expand | #### Signature ```js Toolbar:setCollapse(collapsed: boolean): void ``` **Returns** `void` ## Examples ```js Toolbar:setCollapse(true) ``` ```js Toolbar:setCollapse(false) ``` ## Toolbar:setOpacity() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setopacity Markdown URL: https://androidmacro.com/docs/reference/toolbar/setopacity.md # Toolbar:setOpacity() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setopacity Source file: /docs/reference/toolbar/setopacity.md --- Set the toolbar opacity. #### Parameters | Parameters | Type | Description | | ---------- | ------ | ------------------- | | opacity | number | The desired opacity | #### Signature ```js Toolbar:setOpacity(opacity: number): void ``` **Returns** `void` ## Notes - Values are clamped between `0.1` and `1.0` ## Example ```js Toolbar:setOpacity(0.5) ``` ## Toolbar:setPosition() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setposition Markdown URL: https://androidmacro.com/docs/reference/toolbar/setposition.md # Toolbar:setPosition() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setposition Source file: /docs/reference/toolbar/setposition.md --- Move the floating toolbar to a specific screen position. #### Parameters | Parameters | Type | Description | | ---------- | ------ | ----------------------- | | x | number | The target x coordinate | | y | number | The target y coordinate | #### Signature ```js Toolbar:setPosition(x: number, y: number): void ``` ```js Toolbar:setPosition(point: Point): void ``` **Returns** `void` ## Examples ```js Toolbar:setPosition(100, 200) ``` ```js Toolbar:setPosition(Point(320, 640)) ``` ## Toolbar:setScale() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setscale Markdown URL: https://androidmacro.com/docs/reference/toolbar/setscale.md # Toolbar:setScale() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setscale Source file: /docs/reference/toolbar/setscale.md --- Set the toolbar scale factor. #### Parameters | Parameters | Type | Description | | ----------- | ------ | ----------------- | | scaleFactor | number | The desired scale | #### Signature ```js Toolbar:setScale(scaleFactor: number): void ``` **Returns** `void` ## Notes - Values are clamped between `0.25` and `3.0` ## Example ```js Toolbar:setScale(1.25) ``` ## Toolbar:setSnap() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setsnap Markdown URL: https://androidmacro.com/docs/reference/toolbar/setsnap.md # Toolbar:setSnap() Canonical URL: https://androidmacro.com/docs/reference/toolbar/setsnap Source file: /docs/reference/toolbar/setsnap.md --- Enable or disable edge snap mode for the toolbar. #### Parameters | Parameters | Type | Description | | ---------- | ------- | ---------------------------------- | | snapped | boolean | `true` to snap, `false` to expand | #### Signature ```js Toolbar:setSnap(snapped: boolean): void ``` **Returns** `void` ## Examples ```js Toolbar:setSnap(true) ``` ```js Toolbar:setSnap(false) ``` ## Toolbar:show() Canonical URL: https://androidmacro.com/docs/reference/toolbar/show Markdown URL: https://androidmacro.com/docs/reference/toolbar/show.md # Toolbar:show() Canonical URL: https://androidmacro.com/docs/reference/toolbar/show Source file: /docs/reference/toolbar/show.md --- Show the floating toolbar. #### Signature ```js Toolbar:show(): void ``` **Returns** `void` ## Example ```js if Toolbar:isAvailable() then Toolbar:show() end ``` ## Toolbar Canonical URL: https://androidmacro.com/docs/reference/toolbar/toolbar Markdown URL: https://androidmacro.com/docs/reference/toolbar/toolbar.md # Toolbar Canonical URL: https://androidmacro.com/docs/reference/toolbar/toolbar Source file: /docs/reference/toolbar/toolbar.md --- Utility module for controlling the floating Android Macro toolbar from Lua. ## Methods ### isAvailable(): boolean Check whether the toolbar service is running. ### isVisible(): boolean Check whether the toolbar is currently visible. ### show(): void Show the toolbar. ### hide(): void Hide the toolbar. ### setPosition(x: number, y: number): void ### setPosition(point: Point): void Move the toolbar to a screen position. ### setScale(scaleFactor: number): void ### getScale(): number Change or read the toolbar scale. ### setOpacity(opacity: number): void ### getOpacity(): number Change or read the toolbar opacity. ### setSnap(snapped: boolean): void Enable or disable edge snap mode. ### setCollapse(collapsed: boolean): void Enable or disable collapsed circle mode. ### isSnapped(): boolean Check whether the toolbar is currently in a snapped state. ## Notes - Except for `isAvailable()`, these methods require the toolbar service to be running - `setScale()` is clamped between `0.25` and `3.0` - `setOpacity()` is clamped between `0.1` and `1.0` ## Touch Canonical URL: https://androidmacro.com/docs/reference/touch Markdown URL: https://androidmacro.com/docs/reference/touch.md # Touch Canonical URL: https://androidmacro.com/docs/reference/touch Source file: /docs/reference/touch/_category_.json --- Learn about touch interaction methods for Android automation. ## Pages - [Touch:dispatch()](https://androidmacro.com/docs/reference/touch/dispatch.md) - [Touch:down()](https://androidmacro.com/docs/reference/touch/down.md) - [Touch:exit()](https://androidmacro.com/docs/reference/touch/exit.md) - [Touch:init()](https://androidmacro.com/docs/reference/touch/init.md) - [Touch:move()](https://androidmacro.com/docs/reference/touch/move.md) - [Touch](https://androidmacro.com/docs/reference/touch/touch.md) - [Touch:up()](https://androidmacro.com/docs/reference/touch/up.md) ## Touch:dispatch() Canonical URL: https://androidmacro.com/docs/reference/touch/dispatch Markdown URL: https://androidmacro.com/docs/reference/touch/dispatch.md # Touch:dispatch() Canonical URL: https://androidmacro.com/docs/reference/touch/dispatch Source file: /docs/reference/touch/dispatch.md --- Dispatches all pending touch events to the system. This method is useful when you want to ensure all touch events are processed immediately. #### Signature ```js dispatch(): void ``` ## Returns - Type: `void` ## Examples ```js Touch:init() -- Perform a series of touch actions Touch:down(100, 200) Touch:move(300, 400) Touch:up() -- Dispatch all pending events Touch:dispatch() -- You can also dispatch after each action if needed Touch:down(500, 600) Touch:dispatch() Touch:move(700, 800) Touch:dispatch() Touch:up() Touch:dispatch() ``` ## Touch:down() Canonical URL: https://androidmacro.com/docs/reference/touch/down Markdown URL: https://androidmacro.com/docs/reference/touch/down.md # Touch:down() Canonical URL: https://androidmacro.com/docs/reference/touch/down Source file: /docs/reference/touch/down.md --- Performs a touch down action at the specified coordinates or point. #### Signature ```js down(x: number, y: number): void down(fingerId: number, x: number, y: number): void down(fingerId: number, point: Point): void down(point: Point): void ``` ## Parameters | Parameter | Type | Description | | ---------- | -------- | ---------------------------------------------------- | | `fingerId` | `number` | The ID of the finger to use for the touch (optional) | | `x` | `number` | The x-coordinate of the touch point | | `y` | `number` | The y-coordinate of the touch point | | `point` | `Point` | A point object containing x and y coordinates | ## Returns - Type: `void` ## Examples ```js Touch:init() -- Simple touch down at coordinates Touch:down(100, 200) -- Touch down with finger ID Touch:down(1, 100, 200) -- Touch down using Point local point = Point(100, 200) Touch:down(point) -- Touch down with finger ID using Point Touch:down(1, point) ``` ## Touch:exit() Canonical URL: https://androidmacro.com/docs/reference/touch/exit Markdown URL: https://androidmacro.com/docs/reference/touch/exit.md # Touch:exit() Canonical URL: https://androidmacro.com/docs/reference/touch/exit Source file: /docs/reference/touch/exit.md --- Exits and cleans up the touch interface. This method should be called when you're done using the touch interface. #### Signature ```js exit(): void ``` ## Returns - Type: `void` - Throws an exception if cleanup fails. ## Touch:init() Canonical URL: https://androidmacro.com/docs/reference/touch/init Markdown URL: https://androidmacro.com/docs/reference/touch/init.md # Touch:init() Canonical URL: https://androidmacro.com/docs/reference/touch/init Source file: /docs/reference/touch/init.md --- Initializes the touch interface. This method must be called before using any other touch methods. #### Signature ```js init(): void ``` ## Returns - Type: `void` - Throws an exception if initialization fails. ## Touch:move() Canonical URL: https://androidmacro.com/docs/reference/touch/move Markdown URL: https://androidmacro.com/docs/reference/touch/move.md # Touch:move() Canonical URL: https://androidmacro.com/docs/reference/touch/move Source file: /docs/reference/touch/move.md --- Performs a touch move action to the specified coordinates or point. #### Signature ```js move(x: number, y: number): void move(fingerId: number, x: number, y: number): void move(fingerId: number, point: Point): void move(point: Point): void ``` ## Parameters | Parameter | Type | Description | | ---------- | -------- | ---------------------------------------------------- | | `fingerId` | `number` | The ID of the finger to use for the touch (optional) | | `x` | `number` | The x-coordinate of the touch point | | `y` | `number` | The y-coordinate of the touch point | | `point` | `Point` | A point object containing x and y coordinates | ## Returns - Type: `void` ## Examples ```js Touch:init() -- Simple touch move to coordinates Touch:move(100, 200) -- Touch move with finger ID Touch:move(1, 100, 200) -- Touch move using Point local point = Point(100, 200) Touch:move(point) -- Touch move with finger ID using Point Touch:move(1, point) ``` ## Touch Canonical URL: https://androidmacro.com/docs/reference/touch/touch Markdown URL: https://androidmacro.com/docs/reference/touch/touch.md # Touch Canonical URL: https://androidmacro.com/docs/reference/touch/touch Source file: /docs/reference/touch/touch.md --- Interface for handling touch interactions on Android devices. ## Methods | Method | Description | | ------------ | --------------------------------------- | | `init()` | Initializes the touch interface | | `down()` | Performs a touch down action | | `move()` | Performs a touch move action | | `up()` | Performs a touch up action | | `exit()` | Exits and cleans up the touch interface | | `dispatch()` | Dispatches all pending touch events | ## Examples ```js Touch:init() -- Perform a simple tap Touch:down(100, 200) Touch:up() -- Perform a swipe Touch:down(100, 200) Touch:move(300, 400) Touch:up() -- Clean up Touch:exit() ``` ## Touch:up() Canonical URL: https://androidmacro.com/docs/reference/touch/up Markdown URL: https://androidmacro.com/docs/reference/touch/up.md # Touch:up() Canonical URL: https://androidmacro.com/docs/reference/touch/up Source file: /docs/reference/touch/up.md --- Performs a touch up action, releasing the touch at the current position. #### Signature ```js up(): void up(fingerId: number): void ``` ## Parameters | Parameter | Type | Description | | ------------ | ---------- | ------------------------------------------ | | `fingerId` | `number` | The ID of the finger to release (optional) | ## Returns - Type: `void` ## Examples ```js Touch:init() -- Simple touch up (releases all fingers) Touch:up() -- Touch up for specific finger Touch:up(1) -- Complete touch sequence Touch:down(100, 200) Touch:move(300, 400) Touch:up() -- Multi-finger touch sequence Touch:down(0, 100, 200) Touch:down(1, 300, 400) Touch:move(0, 150, 250) Touch:move(1, 350, 450) Touch:up(0) Touch:up(1) ``` ## Utils Canonical URL: https://androidmacro.com/docs/reference/utils Markdown URL: https://androidmacro.com/docs/reference/utils.md # Utils Canonical URL: https://androidmacro.com/docs/reference/utils Source file: /docs/reference/utils/_category_.json --- Learn the most important android macro concepts. ## Pages - [Utils:alert()](https://androidmacro.com/docs/reference/utils/alert.md) - [Utils:interpolatePoints()](https://androidmacro.com/docs/reference/utils/interpolatepoints.md) - [Utils:sleep()](https://androidmacro.com/docs/reference/utils/sleep.md) - [Utils:toast()](https://androidmacro.com/docs/reference/utils/toast.md) - [Utils](https://androidmacro.com/docs/reference/utils/utils.md) ## Utils:alert() Canonical URL: https://androidmacro.com/docs/reference/utils/alert Markdown URL: https://androidmacro.com/docs/reference/utils/alert.md # Utils:alert() Canonical URL: https://androidmacro.com/docs/reference/utils/alert Source file: /docs/reference/utils/alert.md --- Show alert to the screen #### Signature ```js Utils:alert(message: string, title: string): void ``` **Returns** `void` ## Utils:interpolatePoints() Canonical URL: https://androidmacro.com/docs/reference/utils/interpolatepoints Markdown URL: https://androidmacro.com/docs/reference/utils/interpolatepoints.md # Utils:interpolatePoints() Canonical URL: https://androidmacro.com/docs/reference/utils/interpolatepoints Source file: /docs/reference/utils/interpolatepoints.md --- Generate a list of points between start and end **Parameters** - `type`: The interpolation type. Can be `"linear"` (default) or `"bezier"`. #### Signature ```js Utils:interpolatePoints(start: Point, end: Point, count: number, type: string): List ``` **Returns** `List` ## Utils:sleep() Canonical URL: https://androidmacro.com/docs/reference/utils/sleep Markdown URL: https://androidmacro.com/docs/reference/utils/sleep.md # Utils:sleep() Canonical URL: https://androidmacro.com/docs/reference/utils/sleep Source file: /docs/reference/utils/sleep.md --- Add sleep to the macro #### Signature ```js Utils:sleep(ms: number): void ``` **Returns** `void` ## Utils:toast() Canonical URL: https://androidmacro.com/docs/reference/utils/toast Markdown URL: https://androidmacro.com/docs/reference/utils/toast.md # Utils:toast() Canonical URL: https://androidmacro.com/docs/reference/utils/toast Source file: /docs/reference/utils/toast.md --- Show toast to the screen #### Signature ```js Utils:toast(text: string): void ``` ```js Utils:toast(text: string, duration: number): void ``` ```js Utils:toast(text: string, params: ToastParams): void ``` **Returns** `void` ## Utils Canonical URL: https://androidmacro.com/docs/reference/utils/utils Markdown URL: https://androidmacro.com/docs/reference/utils/utils.md # Utils Canonical URL: https://androidmacro.com/docs/reference/utils/utils Source file: /docs/reference/utils/utils.md --- Utility class to show toast, alert, sleep and more ## Requirements Canonical URL: https://androidmacro.com/docs/requirements Markdown URL: https://androidmacro.com/docs/requirements.md # Requirements Canonical URL: https://androidmacro.com/docs/requirements Source file: /docs/requirements.md --- ### Android Version - Android 5.0 or higher ### Device Requirements #### For Android 5.0 - 7.0: - Rooted device required - [Android Macro Activator](https://androidmacro.com/apk/androidmacro-activator.apk) app must be installed #### For Android 7.1+: - No root required - Uses built-in Accessibility Service ### Additional Requirements - Media Projection permission must be enabled - Used for screen recording and match detection - Can be enabled in device settings ## Quick Setup Guide 1. Check your Android version in Settings > About Phone 2. For Android 5.0-7.0: - Root your device - Install Android Macro Activator 3. For Android 7.1+: - Enable Accessibility Service for Android Macro 4. Enable Media Projection permission when prompted 5. You're ready to start using Android Macro! ## Setting & Optimizations Canonical URL: https://androidmacro.com/docs/setting Markdown URL: https://androidmacro.com/docs/setting.md # Setting & Optimizations Canonical URL: https://androidmacro.com/docs/setting Source file: /docs/setting/_category_.json --- Learn how to optimize and tune your macro performance through settings like grayscale detection, caching, delays, and best practices for reliable automation. ## Pages - [Best Practices](https://androidmacro.com/docs/setting/best-practices.md) - [Detection Strategies](https://androidmacro.com/docs/setting/detection-strategies.md) - [Tuning Cache Detection](https://androidmacro.com/docs/setting/tuning-cache-detection.md) - [Tuning The Delay](https://androidmacro.com/docs/setting/tuning-delay.md) - [Tuning Grayscale Detection](https://androidmacro.com/docs/setting/tuning-grayscale-detection.md) ## Best Practices Canonical URL: https://androidmacro.com/docs/setting/best-practices Markdown URL: https://androidmacro.com/docs/setting/best-practices.md # Best Practices Canonical URL: https://androidmacro.com/docs/setting/best-practices Source file: /docs/setting/best-practice.md --- Android Macro provides several optimization techniques to improve the performance and reliability of your automation scripts. Here are the key best practices: If you already understand the basics, continue with the advanced guides: - [Detection Strategies](./detection-strategies.md) ## Use Region Detection When searching for elements on screen, limiting the search area can significantly improve performance. ### Why Use Regions? - Faster detection by searching smaller areas - More accurate results by avoiding similar elements elsewhere - Reduced resource usage ### Example: > Interactive Blockly example omitted in Markdown export. ## Cache Detection Results Store detection results in variables when you need to check the same element multiple times: ### Benefits of Caching - Avoid redundant screen scans - Faster execution - Reduced system load ### Example: > Interactive Blockly example omitted in Markdown export. ## Use Appropriate Delays Strategic delays help ensure reliable automation: ### Best Practices for Delays - Add delays after screen transitions - Wait for animations to complete - Allow time for elements to load - Don't use excessive delays ### Example with Smart Delay: > Interactive Blockly example omitted in Markdown export. ## Optimize Image Detection Improve detection accuracy and speed: ### Tips for Image Detection - Use clear, distinctive images - Crop images to essential elements - Consider using grayscale for faster matching - Adjust match scores based on needs ### Example with Optimized Detection: > Interactive Blockly example omitted in Markdown export. ## Use Error Handling Implement robust error handling for reliable automation: ### Error Handling Strategies - Check if elements exist before interaction - Provide fallback actions - Set reasonable timeouts - Log important events ### Example with Error Handling: > Interactive Blockly example omitted in Markdown export. ## Performance Monitoring Monitor and optimize your macro's performance: ### Monitoring Tips - Track execution times - Monitor resource usage - Identify bottlenecks - Test on different devices ## General Best Practices 1. **Keep Scripts Modular** - Break complex tasks into functions - Reuse common operations - Maintain clean, organized code 2. **Regular Testing** - Test under different conditions - Verify on multiple devices - Check edge cases - Validate error handling 3. **Resource Management** - Release resources when done - Clear variables when no longer needed - Avoid memory leaks 4. **Documentation** - Comment your code - Document assumptions - Explain complex logic - Keep track of changes By following these best practices, you can create more efficient, reliable, and maintainable Android Macro automations. ## Detection Strategies Canonical URL: https://androidmacro.com/docs/setting/detection-strategies Markdown URL: https://androidmacro.com/docs/setting/detection-strategies.md # Detection Strategies Canonical URL: https://androidmacro.com/docs/setting/detection-strategies Source file: /docs/setting/detection-strategies.md --- Once your macro goes beyond simple taps, the biggest factor in reliability is not the click itself, but how you detect the target. Advanced macros work best when they choose the right detection strategy for the UI they are automating. ## Start With the Simplest Reliable Signal Before tuning settings, first choose the most stable signal: 1. Use fixed coordinates only when the target position never changes 2. Use image detection when the visual shape is stable and distinctive 3. Use text detection when labels are easier to recognize than icons 4. Use a smaller `Region()` when you already know roughly where the target should appear If multiple strategies work, prefer the one with the smallest search area and the least ambiguity. ## Screen vs Region The most common performance mistake is searching the full screen for everything. Use `Screen` when: - the target can appear almost anywhere - you are building the first version of a macro - you are exploring a new app flow Use `Region` when: - the target always appears in a known section of the UI - the screen contains repeated icons or repeated text - you want faster and more stable matching ```js local actionArea = Region(900, 1600, 1080, 2200) actionArea:click("continue-button.jpg") ``` ## Fit Region Technique One of the most useful advanced techniques is what you described as `fit region`. The idea is: 1. Find the object once using `Screen:find()` 2. Convert that match into a fitted `Region` using `result:getRegion()` 3. Reuse that fitted region for the next searches if the object size stays stable This works well when: - the object always has the same width and height - the object contents may change, but its container area stays consistent - the full-screen search is expensive and repeated often ```js local result = Screen:find("inventory-panel.jpg") if result then local fitRegion = result:getRegion() local collectButton = fitRegion:find("collect-button.jpg") if collectButton then fitRegion:click("collect-button.jpg") end end ``` Why this is powerful: - the first full-screen search is the expensive step - once the object is found, all later searches are limited to the fitted bounds - this can reduce OCR and image matching cost significantly in repeated flows Use fit region when: - you have a stable panel, card, popup, slot, or container - the macro repeatedly interacts inside the same matched object - the same object appears in different positions but keeps the same dimensions Avoid using fit region when: - the object is heavily resized between screens or devices - the target area expands or collapses dynamically - the first match is too generic and may bind to the wrong container In practice, fit region is one of the best ways to convert a slow `Screen` macro into a fast `Region` macro without hardcoding coordinates. ## Image Detection vs Text Detection ### Prefer image detection when: - the target is mostly graphical - the UI language may change - the text is stylized or rendered inside a button - OCR struggles because the text is too small or low contrast ### Prefer text detection when: - the label changes position but keeps the same wording - the same visual component appears in many themes or states - the button shape changes but the label stays readable - you need to match text generated dynamically by the app ## Word-by-Word vs Line-by-Line OCR When using text detection, the detection method matters: - Use `setDetectionMethod(1)` for a single word or very short label - Use `setDetectionMethod(2)` when the target is a phrase or full line ```js Screen:click("Login", ClickParams():setDetectionType("TEXT"):setDetectionMethod(1)) ``` ```js Screen:wait("Your session has expired", 5000, FinderParams():setDetectionType("TEXT"):setDetectionMethod(2)) ``` ## Tune Match Score Gradually A match score that is too high causes misses. A score that is too low causes false positives. A practical tuning process: 1. Start with the default score 2. If the target is missed, lower the score slightly 3. If the wrong thing is matched, increase the score slightly 4. If both happen, reduce the search area before changing the score further In most cases, reducing ambiguity with `Region()` is safer than pushing match score too aggressively. ## Use Grayscale Only When It Helps Grayscale can improve speed and sometimes improve consistency, but it is not automatically better. Use grayscale when: - the target is defined more by shape than color - lighting or color shifts make matching unstable - you want faster matching on lower-end devices Avoid relying on grayscale when: - color is the main difference between similar targets - you are trying to distinguish active and inactive states by color ## Dynamic Scaling If the same macro runs across devices with different resolutions, dynamic scaling can help image detection remain usable. Use dynamic scaling when: - the template was captured on one device but executed on another - the same app layout is resized across phones or tablets But if the UI is already highly consistent on a single device, a well-cropped template plus a good region is usually more stable than over-tuning scaling. ## Crop Templates Aggressively A good template should contain only what makes the target unique. Good template: - the icon itself - the unique label area - the minimum stable visual pattern Bad template: - large surrounding whitespace - backgrounds that animate - content that changes every run - nearby elements that are not part of the target ## Use Two-Step Detection for Hard Screens When a screen is noisy, use a staged approach: 1. Wait for a stable anchor element 2. Narrow the search area 3. Detect the final target inside that area ```js Screen:wait("settings-title.jpg", 5000) local footerArea = Region(0, 1700, 1080, 2400) footerArea:click("save-button.jpg") ``` ## Recommended Pattern For advanced macros, this is usually the safest order: 1. Wait for a stable state 2. Restrict the search area 3. Choose image or text detection intentionally 4. Tune score only after reducing ambiguity 5. Verify the result before continuing ## Related Pages - [Best Practices](/docs/setting/best-practices) - [Detect Image/Text](/docs/basic/detect-image-or-text) - [Wait Until Image or Text Appears or Vanishes](/docs/basic/wait-image-or-text) ## Tuning Cache Detection Canonical URL: https://androidmacro.com/docs/setting/tuning-cache-detection Markdown URL: https://androidmacro.com/docs/setting/tuning-cache-detection.md # Tuning Cache Detection Canonical URL: https://androidmacro.com/docs/setting/tuning-cache-detection Source file: /docs/setting/tuning-cache-detection.md --- Cache detection is an optimization feature that can significantly improve your macro's performance by reducing the number of screen captures required during execution. ## Understanding Cache Detection By default, your macro captures the screen every time it needs to perform text or image detection. While this ensures accuracy, it can be computationally intensive. Cache detection allows you to store and reuse the last captured frame, reducing the overhead of repeated screen captures. ## Using Cache Settings ### Enabling Cache ```js # turn cache on Settings:cacheOn(); ``` When cache is enabled: - The macro stores the last captured frame in temporary memory - Subsequent detection operations use the cached frame instead of capturing a new one - Significantly reduces CPU and memory usage during rapid detection operations ### Disabling Cache ```js # turn cache off Settings:cacheOff(); ``` When cache is disabled: - The macro captures a new frame for each detection operation - Provides the most up-to-date screen information - Useful when the screen content changes frequently ## Best Practices 1. **Enable cache when**: - Performing multiple detections in quick succession - The screen content remains relatively static - Performance optimization is a priority 2. **Disable cache when**: - Screen content changes rapidly - Absolute detection accuracy is required - Memory usage is a concern ## Example Usage ```js # Enable cache for a sequence of related detections Settings:cacheOn(); Screen:find('Button 1.jpg'); Screen:find('Button 2.jpg'); Screen:find('Button 3.jpg'); # Disable cache when done Settings:cacheOff(); ``` ## Related Settings You can combine cache detection with other optimization settings: - `Settings:grayscaleOn()` - Further improve performance by processing in grayscale - `Settings:setScanInterval()` - Add delays between detection operations - `Settings:setMinScore()` - Adjust detection accuracy threshold ## Tuning The Delay Canonical URL: https://androidmacro.com/docs/setting/tuning-delay Markdown URL: https://androidmacro.com/docs/setting/tuning-delay.md # Tuning The Delay Canonical URL: https://androidmacro.com/docs/setting/tuning-delay Source file: /docs/setting/tuning-delay.md --- Delays between macro actions help ensure reliable automation by controlling the timing of operations. Android Macro provides options to fine-tune these inter-action delays. ## Understanding Action Delays Action delays are pauses inserted between macro operations that: - Prevent actions from executing too quickly - Allow the system to process each operation - Improve reliability of automation sequences - Help match human-like interaction timing ## Using Delay Settings ### Setting Global Delays You can set a global delay that applies to all macros in `Settings` tabs: ![Home Page](/img/macro-configuration.jpg) ## Tuning Grayscale Detection Canonical URL: https://androidmacro.com/docs/setting/tuning-grayscale-detection Markdown URL: https://androidmacro.com/docs/setting/tuning-grayscale-detection.md # Tuning Grayscale Detection Canonical URL: https://androidmacro.com/docs/setting/tuning-grayscale-detection Source file: /docs/setting/tuning-grayscale-detection.md --- Grayscale detection is an optimization feature that can improve detection performance by converting images to grayscale before processing. ## Understanding Grayscale Detection When enabled, grayscale detection: - Converts color images to grayscale (black and white) before processing - Reduces the amount of data that needs to be processed - Can improve detection speed while maintaining accuracy for many use cases ## Using Grayscale Settings #### Enabling Grayscale for global > Interactive Blockly example omitted in Markdown export. #### Enabling Grayscale for find image block > Interactive Blockly example omitted in Markdown export. ## Text Canonical URL: https://androidmacro.com/docs/text Markdown URL: https://androidmacro.com/docs/text.md # Text Canonical URL: https://androidmacro.com/docs/text Source file: /docs/text/_category_.json --- Blocks for working with text strings. ## Pages - [Creating Text](https://androidmacro.com/docs/text/creation.md) - [Formatting](https://androidmacro.com/docs/text/formatting.md) - [Text Manipulation](https://androidmacro.com/docs/text/manipulation.md) - [Searching Text](https://androidmacro.com/docs/text/searching.md) ## Creating Text Canonical URL: https://androidmacro.com/docs/text/creation Markdown URL: https://androidmacro.com/docs/text/creation.md # Creating Text Canonical URL: https://androidmacro.com/docs/text/creation Source file: /docs/text/creation.md --- ## Text String The basic block for creating an exact piece of text. > Interactive Blockly example omitted in Markdown export. ## Join Text Combines multiple pieces of text into one long string. > Interactive Blockly example omitted in Markdown export. - You can add more inputs by clicking the gear icon (mutator). - **Example**: Joining "Score: " and the value of a variable `score`. ## Append Text Adds text to the end of an existing variable. > Interactive Blockly example omitted in Markdown export. ## Formatting Canonical URL: https://androidmacro.com/docs/text/formatting Markdown URL: https://androidmacro.com/docs/text/formatting.md # Formatting Canonical URL: https://androidmacro.com/docs/text/formatting Source file: /docs/text/formatting.md --- # Formatting Text ## Change Case Converts text to Uppercase, Lowercase, or Title Case. > Interactive Blockly example omitted in Markdown export. - **UPPER CASE**: "hello" -> "HELLO" - **lower case**: "HELLO" -> "hello" - **Title Case**: "hello world" -> "Hello World" ## Trim Spaces Removes spaces from the beginning, end, or both sides of a text. > Interactive Blockly example omitted in Markdown export. - **BOTH**: " hello " -> "hello" - **LEFT**: " hello" -> "hello" - **RIGHT**: "hello " -> "hello" ## Text Manipulation Canonical URL: https://androidmacro.com/docs/text/manipulation Markdown URL: https://androidmacro.com/docs/text/manipulation.md # Text Manipulation Canonical URL: https://androidmacro.com/docs/text/manipulation Source file: /docs/text/manipulation.md --- ## Text Length Returns the number of characters in a text string. > Interactive Blockly example omitted in Markdown export. - "abc" -> 3 - "" (empty) -> 0 ## Is Empty? Checks if the text contains no characters. Returns `true` or `false`. > Interactive Blockly example omitted in Markdown export. ## Reverse Text Reverses the order of characters in the text. > Interactive Blockly example omitted in Markdown export. - "hello" -> "olleh" ## Searching Text Canonical URL: https://androidmacro.com/docs/text/searching Markdown URL: https://androidmacro.com/docs/text/searching.md # Searching Text Canonical URL: https://androidmacro.com/docs/text/searching Source file: /docs/text/searching.md --- ## Find Substring Finds where a piece of text appears inside another. > Interactive Blockly example omitted in Markdown export. - **First occurrence**: Finds the first match from the start. - **Last occurrence**: Finds the last match. - **Result**: Returns the position number (1 = first letter). Returns 0 if not found. ## Get Letter at Index Gets the character at a specific position. > Interactive Blockly example omitted in Markdown export. - **#**: Get letter at specific number. - **Last**: Get the very last letter. - **Random**: Get a random letter. ## Welcome Canonical URL: https://androidmacro.com/docs/welcome Markdown URL: https://androidmacro.com/docs/welcome.md # Welcome Canonical URL: https://androidmacro.com/docs/welcome Source file: /docs/welcome.md --- Welcome to Android Macro documentation page. This page was created to help you understand the features that Android Macro offers. Creating macros in this app can be as simple or as complex as you need them to be, depending on your requirements. You can design everything from simple clicks to more advanced tasks, such as text and image detection, making your macros more powerful. Android Macro uses a scripting language called Lua. If you are not familiar with Lua, please visit the official [Lua Website](https://www.lua.org/docs.html) for more information. ## Getting Started Get started by downloading **[Android Macro app](https://play.google.com/store/apps/details?id=com.androidmacro)**. ## Working with AI Canonical URL: https://androidmacro.com/docs/working-with-ai Markdown URL: https://androidmacro.com/docs/working-with-ai.md # Working with AI Canonical URL: https://androidmacro.com/docs/working-with-ai Source file: /docs/llm-access.md --- Android Macro docs can now be consumed in a more LLM-friendly way. This gives you three different access patterns: 1. Open any docs page as plain markdown by appending `.md` 2. Load the curated docs index from `/llms.txt` ## Markdown Mirror Every docs route now has a markdown mirror. Example: - HTML page: `https://androidmacro.com/docs/basic/how-to-use` - Markdown page: `https://androidmacro.com/docs/basic/how-to-use.md` This is useful when: - you want to paste a page into an LLM - you want an agent to fetch the clean docs version instead of parsing HTML - you want stable text for prompt context ## llms.txt The site root exposes an `llms.txt` index: ```js https://androidmacro.com/llms.txt ``` This file is a curated map of the docs for LLM use. It points models and tools toward the most important pages first, then links out to markdown versions of the docs. Related files: - `https://androidmacro.com/llms-full.txt` - `https://androidmacro.com/llms-sitemap.txt` Use them like this: - `llms.txt` for a curated starting point - `llms-full.txt` when you want one large export of the docs corpus - `llms-sitemap.txt` when you want a machine-friendly list of markdown URLs ## Why This Helps HTML docs are designed for humans. LLMs usually do better with: - markdown instead of full page HTML - a curated index instead of crawling every route blindly That is why this setup uses both: - `.md` mirrors for raw page access - `llms.txt` style discovery ## Current Architecture The markdown mirrors and `llms.txt` files are generated into the Docusaurus `static` output, so they are deployed together with the docs site. ## Notes - Category landing pages also get markdown mirrors, such as `https://androidmacro.com/docs/reference/storage.md` - The generated markdown is designed for LLM consumption, so some interactive embeds are replaced with short notes - Rebuild the docs site after content changes so the markdown mirrors and `llms.txt` stay in sync ## Related Pages - [Detection Strategies](/docs/setting/detection-strategies) - [How To Use](/docs/basic/how-to-use)