Skip to main content

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.
number
required
X coordinate in pixels from left edge of screen.
number
required
Y coordinate in pixels from top edge of screen.

doubleClick()

Performs a double-tap gesture at specified coordinates.
number
required
X coordinate in pixels.
number
required
Y coordinate in pixels.

longPress()

Performs a long press (press and hold) gesture.
number
required
X coordinate in pixels.
number
required
Y coordinate in pixels.

Content-Based Clicking

clickNodesByContentDescription()

Clicks elements by their accessibility content description.
string
required
Content description text to match (e.g., “Share”, “Like”, “Next”).
This is more reliable than coordinate-based clicking since UI layouts can vary across devices.

Typing & Text Input

simulateTypeInFirstEditableField()

Enters text in the first editable field on screen.
string
required
Text to type into the field.

simulateTypeInSecondEditableField()

Enters text in the second editable field on screen.
string
required
Text to type into the field.

simulateType()

Types text in a field identified by View ID.
string
required
Android View ID of the target field.
string
required
Text to type.

simulateTypeByClass()

Types text in a field by its class name.
string
required
Android class name (e.g., “android.widget.EditText”).
string
required
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.
string
required
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.
string
required
Text or description to search for.
boolean
Returns true if text is found, false otherwise.
This function uses AI vision analysis and may take 1-2 seconds to complete. Use sparingly for critical checks.

Best Practices

UI elements need time to respond. Add 500-1500ms delays after every action.
Content description clicks are more reliable across devices.
Check screen state before performing actions.
Wrap UI automation in try-catch blocks.

Limitations

  • Requires Accessibility Service enabled
  • Coordinates vary by device screen size and resolution
  • Some apps block accessibility interactions
  • Rapid interactions may be rate-limited
  • Background execution may be restricted by Android