Ready-to-use Code ExampleRegionSnapOCR

Find Multiple Texts in Region

Searches the same area for each text in a list with OCR and reports which ones are on screen. Use Region:findAllText() when all of them must be present and Region:findAnyText() when any one is enough.

Completion, parameter hints and type checking. Installation instructions and downloads are hosted on GitHub.

Copyable Example Code

You can paste this into the code editor; still verify target image, region, color, text, and timing values in your own device flow.

-- Check several texts in one area

local labels = { "Start", "Stop", "Settings" }

Snap.screenRefresh()
local region = Region()

for _, label in ipairs(labels) do
  local match = region:findText(label)
  if match then
    toast("Found: " .. label .. " -> " .. match:getX() .. "," .. match:getY())
  else
    toast("Not found: " .. label)
  end
end

Implementation and Adaptation Notes

  • Before running, replace sample values such as image names, text, colors, coordinates, and file paths with your own macro values.
  • For examples that use Region or coordinates, retest the target area on different resolutions and DPI values.
  • Tune mScore, timeout, and scan rate in a test macro first, then move the verified values into the production macro.
  • Avoid overly wide Region areas; a tighter area scans faster and reduces false matches.
  • For OCR examples, keep the text area clean; busy backgrounds or very small text can weaken recognition.