Options
All
  • Public
  • Public/Protected
  • All
Menu

Module accessibility

Index

Variables

Const accessibility

accessibility: Accessibility = ...

Accessibility service instance

Functions

back

  • back(): boolean
  • Simulate back key.

    Returns boolean

    Whether it succeeds.

click

  • click(x: number, y: number): Promise<boolean>
  • Click on the screen at the specified position. The origin is the top left corner. The maximum value is the screen resolution.

    Parameters

    • x: number

      X coordinate

    • y: number

      Y coordinate

    Returns Promise<boolean>

clickText

  • clickText(text: string, index?: number): Promise<boolean>
  • Click text on the screen.

    Parameters

    • text: string

      The text to click.

    • index: number = 0

      The index of the text to click, starting from 0.

    Returns Promise<boolean>

currentPackage

  • currentPackage(clearCache?: boolean): string | null
  • Returns the package name of the last detected running app, usually the package name of the current running app.

    Parameters

    • clearCache: boolean = true

      Whether to clear the cache.

    Returns string | null

    Package name. Returns null if no permission.

home

  • home(): boolean
  • Simulate home key.

    Returns boolean

    Whether it succeeds.

inputText

  • inputText(text: string, index?: number): Promise<boolean>
  • Input text.

    Parameters

    • text: string

      The text to input.

    • index: number = 0

      The index of the input box to input, starting from 0.

    Returns Promise<boolean>

    Whether it succeeds.

lockScreen

  • lockScreen(): boolean
  • Lock screen. Requires Android 9 or higher.

    Returns boolean

    Whether it succeeds.

longClick

  • longClick(x: number, y: number): Promise<boolean>
  • Long press the screen at the specified position.

    Parameters

    • x: number

      X coordinate

    • y: number

      Y coordinate

    Returns Promise<boolean>

openNotifications

  • openNotifications(): boolean
  • Pull out notification bar.

    Returns boolean

    Whether it succeeds.

openQuickSettings

  • openQuickSettings(): boolean
  • Show quick settings (Pull notification bar to the bottom).

    Returns boolean

    Whether it succeeds.

performGesture

  • performGesture(points: Point[], duration: number, delay?: number): Promise<boolean>
  • Simulate gesture.

    Parameters

    • points: Point[]

      Path, represented by an array of points.

    • duration: number

      Swipe time, in milliseconds.

    • delay: number = 0

      Swipe start delay, in milliseconds.

    Returns Promise<boolean>

    A Promise that resolves to whether the gesture is successful.

performGestures

  • Simulate multiple gestures.

    Parameters

    Returns Promise<boolean>

performGlobalAction

  • performGlobalAction(action: number | GlobalAction): boolean
  • Simulate global key.

    Parameters

    • action: number | GlobalAction

      Global key type.

    Returns boolean

    Whether it succeeds.

press

  • press(x: number, y: number, duration: number): Promise<boolean>
  • Press the screen at the specified position for a certain time.

    Parameters

    • x: number

      X coordinate

    • y: number

      Y coordinate

    • duration: number

      Press time, in milliseconds

    Returns Promise<boolean>

    A Promise that resolves to whether the gesture is successful.

scrollBackward

  • scrollBackward(index?: number): Promise<boolean>
  • Scroll up or left.

    Parameters

    • Optional index: number

      The index of the scrollable layout to scroll, starting from 0.

    Returns Promise<boolean>

    Whether it succeeds.

scrollForward

  • scrollForward(index?: number): Promise<boolean>
  • Scroll down or right.

    Parameters

    • Optional index: number

      The index of the scrollable layout to scroll, starting from 0.

    Returns Promise<boolean>

    Whether it succeeds.

select

sendKeyCodeHeadsethook

  • sendKeyCodeHeadsethook(): boolean
  • Simulate enter key. Requires Android 12 or higher.

    Returns boolean

    Whether it succeeds.

setText

  • setText(text: string, index?: number): Promise<boolean>
  • Set text.

    Parameters

    • text: string

      The text to set.

    • index: number = 0

      The index of the input box to set, starting from 0.

    Returns Promise<boolean>

    Whether it succeeds.

showLauncherAllApps

  • showLauncherAllApps(): boolean
  • Show all installed apps. Requires Android 12 or higher.

    Returns boolean

    Whether it succeeds.

swipe

  • swipe(x1: number, y1: number, x2: number, y2: number, duration: number): Promise<boolean>
  • Line swipe.

    Parameters

    • x1: number

      Start X coordinate

    • y1: number

      Start Y coordinate

    • x2: number

      End X coordinate

    • y2: number

      End Y coordinate

    • duration: number

      Swipe time, in milliseconds

    Returns Promise<boolean>

    A Promise that resolves to whether the gesture is successful.

takeScreenshot

  • takeScreenshot(displayId?: number): Promise<Image>
  • Take a screenshot. Requires Android 11 or higher.

    Parameters

    • displayId: number = 0

      Screen ID.

    Returns Promise<Image>

    A Promise that resolves to the screenshot image.

togglePowerDialog

  • togglePowerDialog(): boolean
  • Show power dialog.

    Returns boolean

    Whether it succeeds.

toggleRecents

  • toggleRecents(): boolean
  • Show recents.

    Returns boolean

    Whether it succeeds.

toggleSplitScreen

  • toggleSplitScreen(): boolean
  • Split screen. Requires Android 7.0 or higher.

    Returns boolean

    Whether it succeeds.

triggerAccessibilityButton

  • triggerAccessibilityButton(): boolean
  • Simulate accessibility button. Requires Android 12 or higher.

    Returns boolean

    Whether it succeeds.

triggerAccessibilityShortcut

  • triggerAccessibilityShortcut(): boolean
  • Simulate accessibility shortcut. Requires Android 12 or higher.

    Returns boolean

    Whether it succeeds.