No-Code Workspace — Block Reference

ActionBlock usage recipe

MH Smart Replay (SMART_REPLAY)

Plays a recording only while a visual anchor is on screen

Documented for app version 1.0.50Updated:

Block Preview

Captured from the in-app Visual Builder block card in the English UI.

English UI
MH Smart Replay (SMART_REPLAY) block card

What Does It Do?

Plays a recorded gesture sequence when the visual anchor you chose is on screen. The anchor is searched again before every repetition, and repetitions stop as soon as it disappears. Scan settings work as in the Image block.

When to Use?

1

Play a recording only in the right screen state

2

Keep playing while a button is visible and stop when it disappears

How to Use?

1

Choose the scan region and the anchor image; keep Match Confidence and search time tight

2

In the "MH Smart Replay - Replay" section pick the Replay Name; repeat, delay, radius and speed work as in Replay

3

The TRUE and FALSE branches follow the anchor search; without an anchor the recording does not play

Parameters

Anchor and scan

Anchor image, scan region, Match Confidence and search time

Replay Name and playback

Repeat 1–999, delay 0–60,000 ms, Random Radius 0–200 px, speed 0.25x–4x

Release Notes

  • Coming soonv1.0.51

    MH Smart Replay also refuses playback while a background swipe holds fingers; release them with Touch Break (TOUCH_BREAK) before the block.

  • Coming soonv1.0.51

    Each anchor image can get a Condition from its lightbulb (same rules as IMAGE); an image whose condition is not met is not searched.

Example Usage

1

Anchor: claim_button with a tight region; Replay Name claimTap, Repeat 50, delay 500 ms

2

The button is searched before every repetition; when it is gone the repetitions end

Combinations / Used With

1

SMART_REPLAY + LOG: record when the anchor was missing

2

SMART_REPLAY + PANEL_CONTROL: move the panel aside before playback

Tip

Plays a recording only while a visual anchor is on screen

Warnings / Cautions

1

An empty Replay Name, or a missing anchor image or scan region, is a validation error and the macro does not start

2

A wrong or outdated anchor can make the recording play on the wrong screen

Step-by-Step Mastery: Basic → Advanced → Pro

The same block at three levels: a quick start, the real options, and professional techniques.

Basic

Instead of playing a recording directly, SMART_REPLAY first searches the screen for a visual anchor (a reference image). If the anchor is found, replay starts; if not, the flow stops safely and logs once. This way the recording only runs when the screen is in the right state, removing the risk of blindly tapping on the wrong screen.

Advanced

For the anchor you define a template image and a scan Region; you cut down false positives by constraining the match score (mScore, e.g. 0.8) together with the region. When you give a repeat count, the anchor is re-checked on EVERY repetition: the moment the anchor disappears the loop breaks, so no wasted playback once the screen changes. The randomRadius and speedMultiplier settings behave just like in REPLAY. In practice SMART_REPLAY = an IMAGE search + REPLAY merged into one block, plus automatic re-validation each pass.

Pro

This is the key to cross-device robustness: a recorded route is resolution-bound, but because the anchor is a visual landmark it gates playback against screen/DPI differences. Pick an anchor from a stable, rarely-changing UI element (like a header icon), not from a large/variable region such as the whole scene. Constrain the scan region as tightly as possible: you gain speed and avoid mis-locking onto another similar-looking element. Design the no-anchor branch as a quiet fallback: LOG + safe exit or branching to an alternate group instead of throwing. This turns your macro from a brittle coordinate player into a state-aware automation.

Real-World Scenarios — Step-by-Step Recipes

Small, reproducible examples that combine several blocks — build them straight into your own macro.

Play the login gesture only on the login screen
  1. 1Add SMART_REPLAY
  2. 2replayName=loginSwipe
  3. 3Anchor template=login_button, region=bottom-center quadrant
  4. 4mScore=0.85, repeats=1
  5. 5On missing anchor: LOG + end the macro safely
Collect while the button shows, stop when it disappears
  1. 1Add SMART_REPLAY, anchor=claim_button
  2. 2replayName=claimTap, repeats=50
  3. 3The anchor is re-checked each pass; the loop breaks itself when the button disappears
  4. 4replayWaitNextMs=500 leaves breathing room between passes

Which Blocks to Pair With — Pro Combinations

This block is useful on its own — but it shines when paired with the right partners.

+ REPLAY

SMART_REPLAY gives anchor-gated playback; pair it with plain REPLAY where unconditional playback is needed.

+ IMAGE

Reuse the same template in a separate IMAGE check to add validation before/after the anchor.

+ IF_ELSE

To route the no-anchor branch into an explicit decision and steer to an alternate flow.

+ GROUP (loop)

An outer loop lets you wait for the anchor to reappear and retry.

Common Mistakes and Fixes

Picking the anchor from a large/variable region such as the whole screen: slower and more false positives. Choose a small, stable element and a tight region.

Leaving the no-anchor branch empty and assuming all is well: if the anchor is not found, replay is silently skipped. Handle that branch deliberately with LOG or an alternate flow.

Keeping mScore too low (e.g. 0.5): it locks onto another similar-looking element and plays on the wrong screen. 0.8-0.9 is usually a balanced range.

Pro Tips

Because the anchor is re-checked on every repetition, a high repeat count is safe: the loop breaks itself the moment the screen changes, so there is no infinite-playback risk.

If your anchor element changes color between dark/light theme, pick a theme-robust icon or outline; otherwise the match drops when the theme switches.

If you will ship the same recording across many devices, make SMART_REPLAY your default choice: gating coordinate playback on visual state is the most robust approach against device diversity.

Coming soonv1.0.51Each anchor image can get a Condition from its lightbulb (same rules as IMAGE): an image whose condition is not met is not searched, and the condition is checked again on every repetition. If no image stays active, the anchor counts as not found and the recording does not play.

This Block's Code (Editor View)

Lua

The Lua below is what the Code Editor generates for this block with sample settings. Adding cases, branches, actions or loops, or changing settings, extends the generated code accordingly. Study it to see what the block does under the hood, to learn Lua, or to copy and adapt it. Use the Copy button (top-right) to paste it into the Code Editor, or “Try in Editor →” to run it in the live editor.

local _smartMax1 = math.max(1, math.min(999, 1))
local _smartIter1 = 0
local _smartReplayRandomRadiusRef = math.max(0, math.min(200, 0))
local _smartReplayRandomRadius = math.max(0, math.min(200, math.floor((function() local _refLen = tonumber(_smartReplayRandomRadiusRef) or 0; if _refLen ~= _refLen or _refLen == math.huge or _refLen == -math.huge then _refLen = 0 end; _refLen = math.max(0, _refLen); if _refLen == 0 then return 0 end; local _origin = Point(2, 2); local _unitX = Point(3, 2); local _unitY = Point(2, 3); local function _unresolved(_point) return type(_point) == "table" and _point.__mh_point_unresolved == true end; if _origin == nil or _unitX == nil or _unitY == nil or _unresolved(_origin) or _unresolved(_unitX) or _unresolved(_unitY) then error("Reference length mapping failed") end; local _scaleX = math.abs(_unitX:getX() - _origin:getX()); local _scaleY = math.abs(_unitY:getY() - _origin:getY()); return _refLen * math.max(_scaleX, _scaleY) end)() + 0.5)))
while _smartIter1 < _smartMax1 do
 Snap.screenRefresh()
 local _reg3 = Region(0, 0, 100, 100)
 local m2 = (function()
  local _scanOk, _scanValue = pcall(function() return _reg3:find(Asset.image("btn_play"):mScore(0.8), {engine="balanced_image"}) end)
  if not _scanOk then
   _lastMatch = nil
   error(_scanValue, 0)
  end
  return _scanValue
 end)()
 _lastMatch = m2
 if _lastMatch == nil then
  if _smartIter1 == 0 then System.log("SMART_REPLAY anchor not found: SMART_REPLAY") end
  break
 end
 local _srp1 = { repeatCount = 1, waitNextMs = 0, randomRadius = _smartReplayRandomRadius, speedMultiplier = math.max(0.25, math.min(4.0, 1.0)) }
 local _smart_replay_ok4 = Replay.play("route_1", _srp1)
 if not _smart_replay_ok4 then
  error("SMART_REPLAY action returned false: SMART_REPLAY")
 end
 _smartIter1 = _smartIter1 + 1
 if _smartIter1 < _smartMax1 then wait(math.max(0, math.min(60000, 0))) end
end

Note: generated code can evolve across versions; helper names (e.g. _reg1, m1) and internal optimizations may change. The logic and the called APIs reflect the block’s behavior.

Block ↔ Lua Mapping →

Shared Controls for This Block Family

The guidance below is not identical for every block. It summarizes the professional controls that most often repeat in the selected block family.

📍Target Point or Match Center

Choose clearly between a fixed coordinate, "act on match" (the position the previous search found), or an {x}-bound variable/dialog value to define where the action executes. Binding {matchX},{matchY} does not break across devices or resolutions.

🎛Duration and Repeats

Hold time, repeat count, and inter-action delay shape how aggressive or natural the action feels.

🎲Small Offset

Random offsets or waypoints help validate fixed-coordinate tests across different screen layouts. "In-Match Jitter" randomizes the tap inside the match box and uses the configured margin to stay away from target boundaries. Keep repeated UI tests bounded and record a visible result.

🪜Before and After Waits

Before-waits let UI settle before the action; after-waits let the next block see the updated screen state.

Builder vs Lua Boundary

Raw touch pointer lifecycle stays code-first

TOUCH and TOUCH_BREAK cover recipe-style touch flows. Raw pointer choreography such as Touch.down, Touch.move, Touch.up, Touch.dispatch, Touch.reset, Touch.breakAll, and Touch.releaseAfter is not exposed as a first-class builder block.

Touch.downTouch.moveTouch.upTouch.dispatchTouch.resetTouch.breakAllTouch.releaseAfter
Bounded dialog design is builder-backed; freer composition stays code-first

The DIALOG block and dialog designer cover a bounded field set in the builder: Info Text, Text Input, Checkbox, Description, Radio Group, Dropdown, Multi Select, Tab Group, Date Time, Number Range, Slider, Image Picker, Color Picker, File Picker, Recorder Picker, Tag, Signature, and Spacer. The buttons are designed too: the Positive button and Negative button tabs set each button’s text, background, and border color, corner radius, and minimum height next to a preview. Freer Setting.builder composition, multi-step wizard flows, and mixed HUD/dialog choreography still do not map 1:1 into the builder.

Coming soonv1.0.51Two more fields: Agent Detect references (agent_detect_editor) lets the user pick a saved reference set or add and edit references, and Save confirms the selection; Navigation setup editor (navigation_editor) edits a saved map, marker and route from the Dialog and returns the setup and route selection without moving the character.

Setting.builderDialogHudTextViewAgentDetectEditorNavigationEditor
Advanced HTTP request chaining stays code-first

HTTP_GET, HTTP_POST, and HTTP_PUT cover common fixed-method flows; HTTP_REQUEST covers one bounded request with method, header lines, body, content type, query parameters (GET and DELETE), timeout, and a bounded retry. These blocks never throw; they write the status code (-1 on a network failure). Cookie handling, chained request objects, and lower-level client flows still need the code editor.

Request()Request.setCookieRequest.getCookiesCUSTOM_CODE
General programming surfaces stay code-first

The MAP, LIST, JSON_PARSE, REGEX_MATCH, and METRICS blocks cover the everyday cases: map actions, a static list, reading a value from a JSON path, regex match, find, replace, and split, and metrics actions. The rest of the Map, Array, JSON, Regex, and Metrics APIs (for example Array sort, filter, and map) is broader than the builder recipe model and stays on the CUSTOM_CODE and code editor side.

MapArrayJSONRegexMetrics
Low-level runtime and Lua composition stays code-first

Runtime helpers, raw Request objects, Lua built-ins such as print/pcall/xpcall, and free-form object chaining patterns are represented through CUSTOM_CODE or the code editor.

RuntimeRequestprintpcallxpcallCUSTOM_CODE

Debug Mode and Breakpoints

Each block card now exposes an independent breakpoint toggle. When enabled, the breakpoint preference is stored with the block.

Breakpoints are only emitted into runtime code when Debug Mode is enabled from Visual Builder settings. When Debug Mode is off, breakpoints stay saved but do not pause execution.

Use ASSERT for fail-fast validation, and use breakpoints for step-by-step tracing and controlled pauses in the same flow.

Variable Scope

1

Variables defined with SET_VARIABLE are accessible throughout the macro (global scope). All blocks can read/write the same variable.

2

However, a variable defined inside a GROUP will be 'nil' (undefined) until the GROUP executes. Blocks outside the GROUP using this variable may produce unexpected results.

3

FOR_EACH loop variables (item and index) only carry valid values inside the loop body. Outside the loop they are outside local scope and should not be used.

4

TRY_CATCH error variable is only valid within the catch block. If the try block succeeds, the catch branch is not entered and the error variable remains undefined.

5

TIP: Before using a variable inside a GROUP, assign a default value with SET_VARIABLE outside the GROUP. This way the variable won't be nil even if the GROUP has not run.

Inline Expressions

You can embed variable values and calculations into text fields using {{ expression }} syntax. Expressions inside double curly braces are evaluated as Lua code and the result is inserted into the text.

Syntax
{{ expression }}
Examples
Skor: {{ score + 1 }} → "Skor: " .. tostring(score + 1)
{{ name }} kazandı! → tostring(name) .. " kazandı!"
X:{{ x }} Y:{{ y }} → "X:" .. tostring(x) .. " Y:" .. tostring(y)
Supported Blocks
SET_VARIABLELOGCOMPARECLIPBOARD_WRITENOTIFY_TOASTKV_SET
Security Note

Expressions are checked by the sandbox policy. Security-sensitive calls like loadstring, require, debug are automatically blocked.

General Tips

1

Keep scan regions as small as possible — improves speed, reduces false matches.

2

Always add an exit condition when using infinite loops (BREAK, timeout, or conditional exit).

3

Use network operations and error-prone steps inside TRY_CATCH.

4

If you need global error handling, use the Error Handler (ERROR_HANDLER) block as a singleton in the project.

5

Small coordinate offsets (CLICK/SWIPE) improve tap accuracy across different DPI and screen scales.

6

Customize macros with Dialog block — different parameters each run.

7

Define repeating steps once with GROUP_CALL, call from many places.

Cross-macro local library

Local Shared Macro Area

The Local Shared Macro Area moves blocks, variables, dialog fields, gallery assets, and imported media dependencies between macros on the same device. It is device-local, not cloud sync, not Firebase sharing, and not a replacement for public macro sharing.

Professional usage model: put a reusable login flow, common scan region, shared dialog form, variable group, template image, color profile, replay recording, or imported PLAY_SOUND media file into the shared area from one macro, then import it from the relevant + menu in another macro.

VISUAL_BLOCKSVARIABLESDIALOG_FIELDSTEMPLATE_IMAGECOLOR_SWATCHREPLAY_RECORDMEDIA_FILE
1

Send to the shared area

When one item or a multi-selection is active, the shared-area button can copy the selected part from the workspace, group, true/false action branch, dialog, and variables surfaces into the device-local library.

2

Import into another macro

The shared-area entry under the + menu imports the selected item into the surface that opened it. Main workspace, group, action branch, dialog, and variables each receive the compatible item type.

3

Share gallery assets

Gallery items include template images, color swatches, replay records, and imported audio/media files. They can move between macros on the same device so repeated templates, colors, recordings, and PLAY_SOUND media assets do not need to be captured again.

4

Keep it clean

The shared area is not a permanent dumping ground. Delete stale shared items from the shared-library panel; imports create a copy in the target macro and do not rewrite the source macro flow.

Checkpoint: after importing, review block names, linked template/image/color/record/media assets, and variable names in the target macro. The shared area creates a copy; delete stale shared items from the shared-library panel to keep the library clean.

AI assistant

Build a block chain with MH AI in natural language

Tell MH AI what you want in plain language; it proposes the right block sequence and lands it in the workspace after you approve. In the current release it works with cloud providers such as Gemini, Claude, and OpenAI; on-device local models are on the roadmap.

Learn more →