Object MethodParameter Objects

FindParam.engine(value)

Selects the search engine. Image engine keys: balanced_image (default), strict_image, quick_image, color_aware_image, precision_image, small_object_image, edge_image, feature_image and, from 1.0.51, auto_image, gray_image, silhouette_image, orientation_image, pixel_exact_image, rotation_image and sift_image.

Documented for app version 1.0.50Updated:

Detailed Explanation

This section explains when to use the API, how to call it, and which structures it works best with in production flow.

How To Call It

FindParam is a global table: call its functions with a dot (FindParam.<method>(...)), not a colon. The new image engine keys (auto_image, gray_image, silhouette_image, orientation_image, pixel_exact_image, rotation_image, sift_image) and the tol, angle, angleStep, contrast, edge and transparent options require Macro Handler 1.0.51.

When To Use It

Parameter objects work best when prepared in a dedicated variable and reused across search or action calls.

Parameters and Return

Required: value. Returns a FindParam object.

Options and Limits

param is a FindParam or an option table. Table keys: timeout (ms; the region is scanned until the target appears or the time runs out), mScore (0-1, default 0.7; larger values are clamped to 1), scale (0.5-4), sRate (scans per second, 1-30, default 3), engine, method, mode, excludeRegion (a Region or {x, y, w, h} the scan skips) and, for text searches, whitelist, blacklist, case, segment and ocrScript. Image engine keys for engine from 1.0.51: auto_image, gray_image, silhouette_image, orientation_image, pixel_exact_image, rotation_image and sift_image; the earlier keys (balanced_image, strict_image, quick_image, color_aware_image, precision_image, small_object_image, edge_image, feature_image) keep their meaning. smart_reference is a Lua-only appearance matcher: it gathers candidates from several engines over a wider scale range and keeps the one whose whole appearance matches best; an Image block runs this key as balanced_image. Mode settings: pixel_exact_image takes tol 0-64 (default 24), needs the template at its native size and defaults mScore to 0.98; rotation_image takes angle 0-180 (default 30, 180 is a full turn) and angleStep 2-45 (default 10), and angles times scales may not exceed 48; silhouette_image takes contrast and orientation_image takes edge, each "low", "normal" or "high"; sift_image needs a detailed template whose shorter side is at least 64 pixels; transparent = false turns the transparency mask off for this search. auto_image, silhouette_image and rotation_image run from Lua but are not offered in the Image block panel yet. Result:getEngine() reports the engine that actually ran and Result:getAngle() the matched rotation.

Best Combined With

This object is mostly used to prepare input for action APIs such as Region searches, click(), swipe() and Replay playback.

Example Usage

The snippet below is a starter pattern that can be applied directly in runtime flow.

local param = FindParam.engine("gray_image"):timeout(3000)
local match = Region():find(Asset.image("target"), param)

Copyable Progressive Examples

From foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.

Foundation

Shows the shortest direct way to call the API.

Foundation
local param = FindParam.engine("gray_image"):timeout(3000)
local match = Region():find(Asset.image("target"), param)

Simple

Wraps the base call with minimal flow control.

Simple
local stepOk = true
local param = FindParam.engine("gray_image"):timeout(3000)
local match = Region():find(Asset.image("target"), param)
if stepOk then
  wait(200)
end

Practical Flow

A practical pattern for real macros with pcall, logging, and guards.

Practical Flow
local ok, err = pcall(function()
  local param = FindParam.engine("gray_image"):timeout(3000)
  local match = Region():find(Asset.image("target"), param)
end)

if not ok then
  print("API step failed: FindParam.engine: " .. tostring(err))
  requestStop()
end

Detailed

This level packages the API into a reusable helper with error reporting.

Detailed
-- Parameter objects work best when prepared in a dedicated variable and reused across search or action calls.
local function run_engine_step()
  local param = FindParam.engine("gray_image"):timeout(3000)
  local match = Region():find(Asset.image("target"), param)
end

local ok, err = pcall(run_engine_step)
if not ok then
  toast("Step failed")
  print(err)
end

Combined

Combines the API with related structures to form a more realistic workflow.

Combined
-- Rotated search from Lua (Macro Handler 1.0.51 or later)
Snap.screenRefresh()
local region = Region()
local match = region:find(Asset.image("arrow_icon"), { engine = "rotation_image", angle = 180, angleStep = 30, timeout = 3000 })
if match then
  print("engine: " .. tostring(match:getEngine()) .. ", angle: " .. match:getAngle())
  click(match)
end