Skip to main content
rb.ai lets a script ask a model about the screen: where something is (rb.ai.find), what some text says (rb.ai.read), or which of several answers fits (rb.ai.decide). Use it for things you can describe in words but cannot pin down as a pixel color or an image. Before you start:
  • Rebind Pro. rb.ai is part of Rebind Pro, which covers its trial and monthly AI allowance. Calls go through the account signed in to Rebind and each one counts against that allowance, so call on a hotkey or a slow interval, never on every tick.
  • A coroutine. Each call waits for the model, so it must run inside rb.run or a function wrapped in rb.async. Outside one, it raises an error.
  • The ai permission. A script that declares permissions lists ai, or only the calls it uses: ai:find, ai:read, ai:decide. That needs min_sdk=3.10.0 or later. See Permissions.
  • The screen. find and read always send a screenshot, and decide sends one when you pass screen = true, a window or a region. Screen reads work on Windows and macOS. On macOS, turn on Screen capture first; see Platforms.
Every option, return value, and error message is in the rb.ai reference.

Click something you describe

Press a hotkey and the script finds the button by its description, moves the cursor onto it, and clicks. rb.ai.find returns the center of what you described in screen coordinates, or nil when it is not on screen.
Without a window option, find looks at the display under the cursor. Pass { window = "Title" } to look inside one window instead. Describe the target the way you would to a person: its label, color, and where it sits.

Find a small target

Ask the operating system first. A control an app names, such as a button, a menu title, a tab or a window’s close button, has an exact rectangle in rb.screen.elements, with no picture and no AI call, and a quoted name in rb.ai.find('the "Save" button') is answered the same way. Use a picture for what apps do not name: most things in a game, and much of a web page. For those, a whole display is shrunk to at most 1,024 pixels on its long edge before the model sees it, so a small target can come back tens of pixels off. Looking twice helps: the first find gets near it, and a second find with at set to that answer reads a 400 by 160 box around it at full size. Two looks land on a small target more often than one, not every time.
The second look only helps when the first answer lands inside that box. When the first is further off, the target is not in the box, and the second look can return nil or something else nearby that fits the description. Treat nil as not found, describe the target precisely, and check the result before a click that cannot be undone. Each find is one call.

Read a value off the screen

rb.ai.read returns the text you describe, exactly as it appears. When the text is not on screen it returns an empty string, so check for "" before using the result.
A window names the window by title (on macOS, by title or app name), and the call reads the pixels inside that window’s rectangle. If no window matches, the call raises an error naming the title. A minimized or off-screen window also raises. find and read combine: find a label, then read the value printed beside it. The at option reads a small box centered on a point.

Wait for something to happen

rb.ai.decide picks one of the choices you give it and returns the model’s confidence from 0 to 1. This script checks the screen once a minute and stops when it is confident a long job has finished, then tells you.
Without screen = true, a window or a region, decide sends no screenshot. It answers from the question and from state.

Decide from what the script knows

When the script already holds the facts, pass them as state and keep the question for the rule. No screenshot is sent, so the call is faster and needs no screen permission. This script sorts whatever you copied. It needs min_sdk=3.22.0.

Choose between several actions

choices is not limited to yes and no. Give each choice a description when its name alone is ambiguous, pass numbers and lists in state, and put the rule in the question. The third return value also carries what the call cost. This script suggests when to take a break. It needs min_sdk=3.22.0.

Ask about one window

Pass window and decide looks at that window alone, wherever it sits on the screen.

Watch one part of the screen

To ask about one small part of the screen, such as a health bar, pass region = { x, y, w, h } in screen coordinates. The call sends only that rectangle, so far less of it is lost when the picture is shrunk to fit; a whole window usually loses its small detail. This script checks the rectangle every five seconds and warns only when the model’s probability for “yes” is high enough. It needs min_sdk=3.22.0.
How confidence differs from a choice’s probability is under the whole answer.

Keep looks inside one app

A script targeted at an application can promise to read only that application’s window. Add screen:target to its permissions along with a process= or window= target. Then find and read without a window look at the target window instead of the whole display, and Rebind’s install screen shows the narrower grant.
A script that declares permissions needs screen or screen:target for every look, so without one it can still use decide without a screenshot but not find or read. Scoped permissions are in the permissions reference.