Skip to main content

Overview

PhoneClaw provides a suite of utility functions that complement the vision-based automation features. These functions handle common tasks like delays, text-to-speech, app launching, and data manipulation.

Delay Functions

delay()

Pause script execution for a specified duration.
Number
required
Duration to wait in milliseconds (1000ms = 1 second)
Examples:

Text-to-Speech

speakText()

Provide voice feedback during automation.
String
required
The text to speak aloud via device text-to-speech engine
Examples:

App Launching

launchTikTok()

Launch the TikTok application.
Example:
Package: com.zhiliaoapp.musically

launchGmail()

Launch the Gmail application.
Example:
Package: com.google.android.gm
Both launch functions check if the app is installed and provide voice feedback if not found.

Email Automation

sendEmail()

Automated email composition workflow (experimental).
String
required
Recipient email address
String
required
Email subject line
String
required
Email body content
Example:
This is an experimental function that uses vision-based clicking and may need adjustment based on your Gmail version and layout.
How it works:
  1. Launches Gmail
  2. Uses magicClicker() to find compose button
  3. Types recipient in editable field
  4. Types body in text area
  5. Waits with built-in delays between steps

Data Parsing

While there’s no built-in safeInt() function in the current implementation, you can safely parse integers using JavaScript:

Safe Integer Parsing

Parsing Scraped Data

String Utilities

Common String Operations

Accessibility Helpers

Direct Click (Coordinate-Based)

For when you know exact coordinates:
Direct coordinate clicking is less flexible than magicClicker() and may break if UI layout changes.

Device Information

Get Device Details

While not directly exposed as utility functions, PhoneClaw tracks device information:
To access this data, use magicScraper():

Logging and Debugging

Console Logging

Voice Logging

Error Handling Utilities

Retry Logic

Timeout Wrapper

Best Practices

Use Adequate Delays: Always add delays after navigation, app launches, or UI changes to ensure elements are loaded.
Voice Feedback: Use speakText() for important status updates, especially for long-running automations.
Validate Data: Always check scraped data before using it in conditional logic or calculations.
  • After app launch: 3000ms (3 seconds)
  • After button click: 1000-1500ms (1-1.5 seconds)
  • After navigation: 2000ms (2 seconds)
  • After typing: 500-1000ms (0.5-1 second)

Complete Automation Example

See Also