Point

A screen position in pixels, used for clicks, swipes and highlights. Scale and anchor adapt the position to another screen size; the final position is kept within the screen. Read both coordinates with x, y = point.

Syntax

Point(x, y, /, scale="fixed", anchor="none")

Constructor parameters

NameDescription
xNumber
X coordinate in pixels
Required · Positional only
No default
yNumber
Y coordinate in pixels
Required · Positional only
No default
scaleString
How coordinates adapt from the macro screen: fixed keeps pixels; auto scales X by width and Y by height; width or height scales both axes by that dimension. Non-fixed coordinates or an anchor also follow macro screen rotation and app area mapping.
Optional · Positional or named
Default: fixed
anchorString
Reference position for adapting coordinates: none (top-left), center, top, bottom, left, right, top_left, top_right, bottom_left, bottom_right. auto chooses the nearest edge or center.
Optional · Positional or named
Default: none

Returns

Example

origin = Point(0, 0)
target = Point(500, 900)
swipe([
    SwipePoint(origin, speed="NORMAL"),
    SwipePoint(target)
])

Fields

NameDescription
xNumber
Horizontal coordinate in pixels.
yNumber
Vertical coordinate in pixels.
scaleString
How coordinates adapt from the macro screen: fixed keeps pixels; auto scales X by width and Y by height; width or height scales both axes by that dimension. Non-fixed coordinates or an anchor also follow macro screen rotation and app area mapping.
Default: fixed
anchorString
Reference position for adapting coordinates: none (top-left), center, top, bottom, left, right, top_left, top_right, bottom_left, bottom_right. auto chooses the nearest edge or center.
Default: none
Field example
# Read the x, y values of Point
p = Point(500, 900)
x_value = p.x #500
y_value = p.y #900
scale_value = p.scale #FIXED_PIXEL

# Unpack Point into x, y coordinates
x, y = p
Constructor example
# Create a Point with scale/anchor and click that position
p = Point(500, 900, scale="width", anchor="center")
click(p)

Methods

3 methods

Point.offset

Return a new Point shifted by dx and dy after adapting this point to the current screen. Scale the shift using full-screen dimensions, keeping X horizontal and Y vertical. The original Point is unchanged.

Syntax

point.offset(dx, dy, scale=None)

Parameters

NameDescription
dxInt
Horizontal shift in whole pixels: positive moves right, negative moves left. Fractions are rejected.
Required · Positional or named
No default
dyInt
Vertical shift in whole pixels: positive moves down, negative moves up. Fractions are rejected.
Required · Positional or named
No default
scaleString?
Offset scale mode using full-screen dimensions. Defaults to this Point's current scale. Values: fixed, auto, width, height.
Optional · Positional or named
Default: None

Returns

Point — A new Point within the current screen, with scale FIXED_PIXEL and anchor NONE.

Example

# Scale the pixel delta by full-screen width, then add it to Point
target = Point(500, 900, scale="width", anchor="center").offset(120, -80)
print(target)
target.highlight()

Point.highlight

Mark this point with a square outline. Calling again on the same Point replaces its outline. Returns before drawing finishes; only the latest update before the next screen refresh is shown.

Syntax

point.highlight(color="green", line_width=2, region_width=36, auto_hide_ms=0)

Parameters

NameDescription
colorColor | String | Number
Highlight color.
Optional · Positional or named
Default: green
line_widthNumber
Outline thickness in dp; values below 1 become 1.
Optional · Positional or named
Default: 2
region_widthNumber
Square width and height in pixels; values below 1 become 1.
Optional · Positional or named
Default: 36
auto_hide_msNumber
Auto-hide after N milliseconds. 0 disables auto-hide.
Optional · Positional or named
Default: 0

Returns

Region — The highlighted square region centered around the point.

Example

p = Point(500, 900)
p.highlight()

Point.highlight_off

Remove the outline created by this Point.

Syntax

point.highlight_off()

Returns

Point — Returns the same point after turning highlight off.

Example

p = Point(500, 900)
p.highlight("red", 3)
wait(1000)
p.highlight_off()