Overview
ClawScript provides a comprehensive set of functions for automating UI interactions on Android. These functions simulate touch gestures, keyboard input, and screen navigation.All UI automation functions require Android Accessibility Service to be enabled. See Accessibility Service Setup.
Click & Tap Functions
simulateClick()
Simulates a tap at specific screen coordinates.X coordinate in pixels from left edge of screen.
Y coordinate in pixels from top edge of screen.
doubleClick()
Performs a double-tap gesture at specified coordinates.X coordinate in pixels.
Y coordinate in pixels.
longPress()
Performs a long press (press and hold) gesture.X coordinate in pixels.
Y coordinate in pixels.
Content-Based Clicking
clickNodesByContentDescription()
Clicks elements by their accessibility content description.Content description text to match (e.g., “Share”, “Like”, “Next”).
Typing & Text Input
simulateTypeInFirstEditableField()
Enters text in the first editable field on screen.Text to type into the field.
simulateTypeInSecondEditableField()
Enters text in the second editable field on screen.Text to type into the field.
simulateType()
Types text in a field identified by View ID.Android View ID of the target field.
Text to type.
simulateTypeByClass()
Types text in a field by its class name.Android class name (e.g., “android.widget.EditText”).
Text to type.
pressEnterKey()
Simulates pressing the Enter/Return key.Swipe & Scroll Functions
swipeUp()
Simulates an upward swipe gesture (scrolling down the page).swipeDown()
Simulates a downward swipe gesture (scrolling up the page).swipeLeft()
Simulates a left swipe gesture.swipeRight()
Simulates a right swipe gesture.simulateScrollToBottom()
Scrolls to the bottom of a scrollable view.simulateScrollToTop()
Scrolls to the top of a scrollable view.View ID Interactions
clickElementByViewId()
Clicks an element by its Android View ID.Full View ID (e.g., “com.instagram.android:id/profile_tab”).
Complete Workflow Examples
Screen Detection
isTextPresentOnScreen()
Checks if specific text is visible on screen using AI vision.Text or description to search for.
Returns
true if text is found, false otherwise.Best Practices
Always add delays after interactions
Always add delays after interactions
UI elements need time to respond. Add 500-1500ms delays after every action.
Use content descriptions over coordinates
Use content descriptions over coordinates
Content description clicks are more reliable across devices.
Verify state before actions
Verify state before actions
Check screen state before performing actions.
Handle errors gracefully
Handle errors gracefully
Wrap UI automation in try-catch blocks.
Limitations
Related Functions
- delay() - Essential for timing UI interactions
- speakText() - Announce automation steps
- magicClicker() - AI-powered element detection
- magicScraper() - Extract screen information