Runtime v2.81 · Updated Sep 30, 2026

Touch

Static helper for parallel click/swipe actions created by the UI or code via click(..., parallel=True) and swipe(..., parallel=True).

Syntax

Touch

This class cannot be constructed directly.

Parameters

None

Returns

—

Behavior / side effects

Static helper for parallel click/swipe actions created by the UI or code via click(..., parallel=True) and swipe(..., parallel=True). You can collect click/swipe actions and send them together, or inspect click/swipe actions that are active or queued. The helper also supports cancelling active click/swipe actions (Android 8.0+ only).

Execution

  • Blocking: Conditional
  • Thread safety: Limited
  • Parallel execution: Conditional

Android gestures share the device. parallel=True queues a touch id but does not make delay_before or delay_after non-blocking outside collect mode. Within collect mode touches are collected for Touch.send(); Touch.wait() waits for their completion.

Example

Touch.collect()
a = click(Point(300, 900), hold_ms=5000, parallel=True)
b = click(Point(780, 900), hold_ms=1000, delay_before=1000, parallel=True)
sent = Touch.send()
Touch.cancel(a)
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Methods

7 methods

Touch.collect

Enable collect mode for click/swipe calls with parallel=True.

Syntax

Touch.collect()

Parameters

None

Returns

None

Behavior / side effects

Enable collect mode for click/swipe calls with parallel=True. When enabled, parallel click/swipe calls are not sent immediately; they are collected and only sent after Touch.send(). This method works for both UI/code. If Touch.collect() is not enabled, parallel click/swipe calls are sent immediately, and later click/swipe calls must wait for the previous click/swipe to finish before they can run because running a later click/swipe immediately would cancel the previous one. You can intentionally cancel the previous click/swipe with Touch.cancel().

Execution

  • Blocking: No
  • Thread safety: Limited
  • Parallel execution: Conditional

Collect/send and touch-state queries do not wait for gesture completion. Collected commands reach the executor only on Touch.send(); queue snapshots can change immediately.

Example

# Inspect or control collected touches
Touch.collect()
first = click((300, 900), hold_ms=1000, parallel=True)
second = click((780, 900), delay_before=300, parallel=True)
Touch.send()
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Touch.send

Send all click/swipe calls collected by Touch.collect() at once, return their matching numeric ids, then turn off Touch.collect() collection mode.

Syntax

Touch.send()

Parameters

None

Returns

list[Number]

Behavior / side effects

Send all click/swipe calls collected by Touch.collect() at once, return their matching numeric ids, then turn off Touch.collect() collection mode.

Execution

  • Blocking: No
  • Thread safety: Limited
  • Parallel execution: Conditional

Collect/send and touch-state queries do not wait for gesture completion. Collected commands reach the executor only on Touch.send(); queue snapshots can change immediately.

Example

# Inspect or control collected touches
Touch.collect()
first = click((300, 900), hold_ms=1000, parallel=True)
second = click((780, 900), delay_before=300, parallel=True)
Touch.send()
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Touch.queued

Return touch states currently in the queue.

Syntax

Touch.queued()

Parameters

None

Returns

list[TouchState]

Behavior / side effects

Return touch states currently in the queue.

Execution

  • Blocking: No
  • Thread safety: Limited
  • Parallel execution: Conditional

Collect/send and touch-state queries do not wait for gesture completion. Collected commands reach the executor only on Touch.send(); queue snapshots can change immediately.

Example

# Inspect or control collected touches
Touch.collect()
first = click((300, 900), hold_ms=1000, parallel=True)
second = click((780, 900), delay_before=300, parallel=True)
Touch.send()
print(Touch.queued())
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Touch.active

Return active touch states.

Syntax

Touch.active()

Parameters

None

Returns

list[TouchState]

Behavior / side effects

Return active touch states.

Execution

  • Blocking: No
  • Thread safety: Limited
  • Parallel execution: Conditional

Collect/send and touch-state queries do not wait for gesture completion. Collected commands reach the executor only on Touch.send(); queue snapshots can change immediately.

Example

# Inspect or control collected touches
Touch.collect()
first = click((300, 900), hold_ms=1000, parallel=True)
second = click((780, 900), delay_before=300, parallel=True)
Touch.send()
print(Touch.active())
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Touch.all

Return recent and queued/active touch states.

Syntax

Touch.all()

Parameters

None

Returns

list[TouchState]

Behavior / side effects

Return recent and queued/active touch states.

Execution

  • Blocking: No
  • Thread safety: Limited
  • Parallel execution: Conditional

Collect/send and touch-state queries do not wait for gesture completion. Collected commands reach the executor only on Touch.send(); queue snapshots can change immediately.

Example

# Inspect or control collected touches
Touch.collect()
first = click((300, 900), hold_ms=1000, parallel=True)
second = click((780, 900), delay_before=300, parallel=True)
Touch.send()
print(Touch.all())
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Touch.wait

Wait for one numeric id, or every queued/active touch when id is None.

Syntax

Touch.wait(id=None)

Parameters

None

Returns

TouchState | list[TouchState]

Behavior / side effects

Wait for one numeric id, or every queued/active touch when id is None.

Execution

  • Blocking: Yes
  • Thread safety: Limited
  • Parallel execution: Conditional

Waits in the calling flow until the requested time or touch completion. Other flows may continue; pause and stop still apply.

Example

# Inspect or control collected touches
Touch.collect()
first = click((300, 900), hold_ms=1000, parallel=True)
second = click((780, 900), delay_before=300, parallel=True)
Touch.send()
Touch.wait(first)
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

Touch.cancel

Cancel one queued or active touch by numeric id.

Syntax

Touch.cancel(id=None)

Parameters

None

Returns

Boolean | Int

Behavior / side effects

Cancel one queued or active touch by numeric id. When id is None, cancels every queued/active touch and returns the accepted cancel count. Active cancel requires Android 8.0+; Android 7.x scripts fail with a clear error when an active touch is targeted.

Execution

  • Blocking: Conditional
  • Thread safety: Limited
  • Parallel execution: Conditional

Android gestures share the device. parallel=True queues a touch id but does not make delay_before or delay_after non-blocking outside collect mode. Within collect mode touches are collected for Touch.send(); Touch.wait() waits for their completion.

Example

# Inspect or control collected touches
Touch.collect()
first = click((300, 900), hold_ms=1000, parallel=True)
second = click((780, 900), delay_before=300, parallel=True)
Touch.send()
# Active cancellation requires Android 8 or newer
Touch.cancel(second)
Touch.wait()

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs