Ready-to-use Code ExampleRegionAssetSnapFindParam

Wait for Image and Click

Waits until an image appears on screen, then taps it. Region:find() rescans the screen sRate times per second for the FindParam.timeout() duration. Note: Region:wait() waits for a target to disappear, not to appear.

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.

-- Wait for an image to appear, then tap it
-- timeoutMs: how long to wait; scansPerSecond: 1-30; score: 0-1

local timeoutMs = 10000
local scansPerSecond = 5
local score = 0.85

Snap.screenRefresh()
local region = Region()
local param = FindParam.timeout(timeoutMs):sRate(scansPerSecond):mScore(score)

toast("Waiting for the image...")
local match = region:find(Asset.image("continue_button"), param)
if match then
  toast("Image found, tapping")
  click(match)
  wait(500)
else
  toast("Timed out: image not found")
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.