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.aiis 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.runor a function wrapped inrb.async. Outside one, it raises an error. - The
aipermission. A script that declares permissions listsai, or only the calls it uses:ai:find,ai:read,ai:decide. That needsmin_sdk=3.10.0or later. See Permissions. - The screen.
findandreadalways send a screenshot, anddecidesends one when you passscreen = true, awindowor aregion. Screen reads work on Windows and macOS. On macOS, turn on Screen capture first; see Platforms.
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.
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 inrb.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.
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.
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.
Read next to something you found
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.
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 asstate 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
Passwindow 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, passregion = { 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.
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. Addscreen: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.
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.