One Rule

Coordinates are screen pixels. A touch at (x, y) lands on the pixel at (x, y) of the phone’s screen, and every position the API answers (recognized text, detected elements, what a tap hit) is in the same pixels. This holds on every phone, Android and iPhone alike, and for everything that carries a position: Touch, live touch, and the boxes that Get Screen returns for recognized text and detected elements. The usual loop is:
  1. Read the screen.
  2. Find what you want in the image, or in the text and elements returned with it.
  3. Send its position to Touch.

Details

  • The origin (0, 0) is the top-left corner of the screen as it is currently shown. x grows to the right and y grows downward.
  • The size of the coordinate space is the phone’s screen width and height. Get Screen answers that size as width and height.
  • The image itself can be smaller than the screen: when you ask for a maxSide or a region, and on some iPhones whose screen is captured at a lower resolution (360 pixels wide). Then the answer has scale, image pixels per screen pixel: a point at (ix, iy) in the image is at (ix / scale, iy / scale) on the screen. Positions the API answers are already in screen pixels.
  • Coordinates can be fractional (540.5).
  • A coordinate outside the screen is rejected with 400 and the code invalid_request.

Example

A phone reports:
The center of the screen is (540, 1200). A swipe up from near the bottom to near the top, taking 300 milliseconds, is:

Timing

All times are in milliseconds. In Touch, each input’s time is the number of milliseconds since the finger touched down.