click

Press and release each target point. By default, wait for the click to finish before continuing. Parameters accept positional or named arguments in the documented order.

Syntax

click(target, hold_ms=0, offset=(0, 0), random=0, delay_before=0, delay_after=0, parallel=False)

Parameters

NameDescription
targetPoint | tuple[Number, Number] | Match | MatchList
Point, fixed pixel coordinates (x, y), or search results. Use Point for scaling or anchoring. Click every found point; do nothing when no point was found.
Required · Positional or named
No default
hold_msInt
Hold duration in milliseconds
Optional · Positional or named
Default: 0
offsettuple[Number, Number]
Horizontal and vertical pixel offsets added to the final target coordinates.
Optional · Positional or named
Default: (0, 0)
randomNumber | tuple[Number, Number]
Maximum random pixel offset in each direction from the target. A number applies to both axes; (x, y) sets each axis separately. Negative values become 0.
Optional · Positional or named
Default: 0
delay_beforeNumber
Delay before the click in milliseconds.
Optional · Positional or named
Default: 0
delay_afterNumber
Delay after the click in milliseconds.
Optional · Positional or named
Default: 0
parallelBoolean
True: queue the touch and return its numeric id without waiting for completion. After Touch.collect(), wait for Touch.send(); collected touches can overlap with different delay_before values. Cancel with Touch.cancel(id), or cancel all with Touch.cancel().
Optional · Positional or named
Default: False

Returns

Number | list[Number] | None — With parallel=True: one touch id for one point, or a list of ids for multiple points. Otherwise, or when no point was found: None.

Example

# Click screen coordinates with Point or tuple
click(Point(500, 900))
click((500, 900))
click((500, 900), hold_ms=200)
click(Point(500, 900), 0, (0, 0), 10, 0, 500)

match = Region(100, 200, 300, 400).find("start", 3000)
if match.found:
    click(match, offset=(0, 6))

hits = Region(100, 200, 300, 400).find_any(["a", "b"], 3000)
if hits:
    click(hits, random=0)

# Collect two parallel touches, send them together, then wait for the queue
Touch.collect()
a = click(Point(300, 900), parallel=True)
b = click(Point(780, 900), parallel=True)
Touch.send()
Touch.wait()

# Hold p1, then tap p2 after 1 second without releasing p1
Touch.collect()
p1 = click(Point(300, 900), hold_ms=5000, parallel=True)
p2 = click(Point(780, 900), hold_ms=1000, delay_before=1000, parallel=True)
Touch.send()
Touch.cancel(p1)
Touch.wait()