No-Code Workspace — Block Reference

SearchBlock usage recipe

OCR Value (OCR_VALUE)

Reads number from screen and saves to variable

Documented for app version 1.0.50Updated:

Block Preview

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

English UI
OCR Value (OCR_VALUE) block card

Block Preview

Captured from the English Visual Builder block card with the Advanced/extra settings panel expanded.

English UI
OCR Value (OCR_VALUE) advanced settings panel

What Does It Do?

Reads text in the specified region via OCR, extracts the number, and saves to a variable. Optionally compares the read number with a threshold and branches to TRUE/FALSE. Used to automatically read numerical data (price, quantity, time, score, etc.) from screen.

Pro note: turn OCR output into a decision point

OCR_VALUE is not only a reader. When its result variable feeds COMPARE, ASSERT, or SWITCH_CASE, it becomes a data-driven decision surface inside the builder.

Shared Mechanics for Search Blocks

Multiple search regions and excluded regions

IMAGE, TEXT, COLOR and the other search blocks that use the Search Regions editor can define several search regions with + Add Region; OCR_VALUE tries its read regions in order. Inside a search region, Exclude Region skips noisy areas such as a HUD or a badge, and it applies only to the search region it belongs to. From 1.0.51 one search region can hold several excluded regions, each with its own shape and its own variable or Dialog binding.Coming soonv1.0.51

Sticky anchors for edge-aware scaling

You can now assign a sticky anchor to each search region. This brings Region.sticky into the no-code surface so the region can stay aligned to anchors such as top_left, bottom_right, or center when screen geometry changes.

Scan rate, duration, and retry behavior

Search Duration (ms) defines one search window; 0 means a single look. Retry Mode in the Retry & Wait section is Off, Infinite Loop, Retry On True, Retry On False, Wait Until Found, or Wait Until Gone, so a block becomes a one-shot check, a controlled polling step, or a step that waits for a target to appear or to disappear. Retry Timeout (ms, 0 = unlimited) bounds the loop; Scan Rate (Hz) sets scans per second.

Match tuning and device variance

mScore, scale, and scan engine choices matter across themes, display sizes, and rendering differences. Smaller regions plus the right engine dramatically improve builder stability.

When to Use?

1

When you need to read and use a numerical value from screen:

2

Reading a counter or countdown

3

Getting price or quantity info

4

Checking timer/duration value

5

Monitoring a number on an indicator

6

Making decisions based on read value (with threshold comparison)

How to Use?

1

"Add Block" → "OCR Value (OCR_VALUE)"

2

SCAN REGION: Select ONLY the area showing the number. No other text should be in region!

3

OCR SETTING: Choose Auto / Latin / Chinese / Japanese / Korean / Devanagari / Arabic / Cyrillic or enter a supported cataloged OCR locale-routing code (for example fr-CA, zh-Hant, hi-IN, ar, ru, tr)

4

RESULT VARIABLE: Enter name for the read number (default: "ocr_val")

5

COMPARISON (optional):

6

Enable "Compare"

7

Select operator: >=, <=, ==, !=, >, <

8

Enter threshold (e.g., 100)

9

Branches to TRUE/FALSE based on comparison

10

If comparison disabled: Block just reads and saves number, no branching

11

IMPORTANT: This block works even when added alone, but without setting scan region it scans full screen and may give unexpected results!

Parameters

Scan Region

ONLY the area with the number! No other text

Result Variable

Variable for the read number (default: ocr_val)

Comparison Operator

>=, <=, ==, !=, >, < — no branching if disabled

Threshold

Target number for comparison

Search Duration (Advanced)

Re-reads when no number comes out: 0 = up to 3 reads within 750 ms; above 0 = one read per 250 ms of the window (at most 10). While Scale is 1.00 and not bound to a variable, the 2nd read uses scale 1.6 and later reads 2.0

Outputs

ocr_val (number; 0 when unreadable), ocr_raw (raw text), ocr_ok (true/false), ocr_status (ok / empty / invalid / error)

Example Usage

1

Scenario 1: Notify when stock drops below 5

2

OCR_VALUE → scan region: Area showing stock count

3

Result variable: "stock"

4

Comparison: < 5

5

TRUE: LOG "Stock low: {{ stock }}"

6

Scenario 2: Read number and use elsewhere

7

OCR_VALUE → scan region: Area with the number

8

Result variable: "read_number"

9

Comparison: OFF (just read)

10

Use "read_number" variable in later blocks (COMPARE, SET_VARIABLE, LOG, etc.)

Combinations / Used With

1

MOST COMMON COMBINATIONS:

2

OCR_VALUE + COMPARE: Compare read number with another value

3

OCR_VALUE + SET_VARIABLE: Use read value in calculations

4

OCR_VALUE + LOG: Log/monitor read value

5

OCR_VALUE + SWITCH_CASE: Route different branches from the read result

6

OCR_VALUE + MATH_EVAL: Calculate on read value

Tip

Reads number from screen and saves to variable

Warnings / Cautions

1

WARNING:

2

Without setting scan region, it reads full screen and may give wrong results

3

Scan region should contain ONLY the number! Other text causes misreading

4

OCR may fail on small or blurry numbers

5

If the number cannot be read, the variable becomes 0 and ocr_ok becomes false

6

TRUE/FALSE branches dont work when comparison is OFF

7

A failed read does not throw; tell a legitimate 0 from a failed read with ocr_ok and ocr_status

8

NUMERAL LIMITATION: Recognizer selection depends on the chosen OCR family or cataloged routing code; this is not a language-accuracy certification. Arabic and Cyrillic families are included, but unsupported numeral systems or strongly variant glyph shapes may still misread; prefer template_text, IMAGE, or pre-normalized text flows in those cases.

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

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

Basic

The OCR_VALUE block reads text in the scan region via OCR, extracts the number, and saves it to a variable (default: ocr_val). Optionally it compares the read number against a threshold and branches to TRUE/FALSE. Simplest use: select a NARROW region showing the number, name the result variable, and use that variable in later blocks. With comparison off, the block just reads and does not branch. Three extra outputs distinguish read health: ocr_raw carries the raw OCR text, ocr_ok whether the read succeeded (true/false), and ocr_status a status label — use them to tell a legitimate "0" from a failed read (do not consume the value when ocr_ok is false).

Advanced

The OCR Setting (ocrScript) selects the script to read: auto, latin, chinese, japanese, korean, devanagari, arabic, cyrillic, or one of the cataloged OCR locale-routing codes (en, fr, fr-CA, de, zh-Hant, ja, ko, hi, ar, ru, tr, vi, sw, sa ...). These codes route recognizer selection; they are not a per-language accuracy certification. Most numbers are written in Latin digits so auto/latin handles them; but if the digits are shown in a local system like Eastern-Arabic or Devanagari, choose that family (arabic / devanagari ...) explicitly. Family coverage: the Latin/Chinese/Japanese/Korean/Devanagari recognizers use ML Kit and Arabic and Cyrillic use Tesseract; all of them ship with the app and need no internet connection. With comparison enabled, the Operator (>=, <=, ==, !=, >, <) and Threshold compare the read number, routing the result to TRUE/FALSE. The generated code uses Num.parseOcr to turn text into a number; on a read miss it does not throw, writes 0 and sets ocr_ok to false. When no number comes out, the block reads again: with Search Duration 0 up to 3 times within 750 ms, and with a Search Duration above 0 once per 250 ms of that window (at most 10 reads). While Scale is 1.00 and not bound to a variable, the second read uses scale 1.6 and later reads 2.0; any other or bound Scale is used as set. The region must contain ONLY the number: any other text (a label, a unit, a glyph) causes a misread.

Pro

The most critical pitfall is that an unreadable number is written as 0; so that it is never confused with a real 0, check ocr_ok before you use ocr_val. ocr_status gives the reason: ok (number read), empty (no text in the region), invalid (text found but not a number), error (the screen or recognizer could not be read). Draw the region as tightly around the number as possible; the narrower it is, the faster and more accurate OCR becomes. Recognizer selection depends on the chosen family or cataloged routing code; this is not a per-language accuracy certification. Unsupported numeral systems or strongly variant glyphs may misread, in which case prefer template_text/IMAGE or pre-normalization flows. Watch for variable-name collisions: reusing the same result variable in different blocks overwrites the previous value.

Real-World Scenarios — Step-by-Step Recipes

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

Alert when stock drops below 5
  1. 1Add OCR_VALUE and shrink the scan region to ONLY the area with the stock number
  2. 2OCR Setting = auto (for Latin digits)
  3. 3Result variable = "stock"
  4. 4Comparison = enabled, Operator = <, Threshold = 5
  5. 5TRUE: LOG "Stock low: {{ stock }}"
Read a number and separate a failed read
  1. 1Add OCR_VALUE, narrow the region to the number area
  2. 2Result variable = "value", Comparison = OFF (read only)
  3. 3Follow with COMPARE: if ocr_ok == false, WAIT + retry from the top
  4. 4If ocr_ok is true, use value with MATH_EVAL or SET_VARIABLE
  5. 5LOG ocr_status to see the reason

Which Blocks to Pair With — Pro Combinations

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

+ COMPARE

Doing the comparison in a separate COMPARE rather than inside the block lets you handle a failed read explicitly with ocr_ok and build richer conditions.

+ MATH_EVAL

Compute on the read number (e.g. remaining = target - read); since the value lives in a variable it is reused across loop iterations.

+ SWITCH_CASE

Route to multiple branches by the read result; e.g. trigger different actions for low/medium/high ranges.

+ AI_DECISION

Combine numeric reading (OCR_VALUE) and semantic interpretation (AI_DECISION) to make a decision that weighs both the figure and its context.

Common Mistakes and Fixes

Using it without setting a scan region; the block reads the full screen and extracts unwanted numbers. Fix: shrink the region to only the number's area.

Leaving other text (a label, a unit) beside the number in the region and getting a misread. Fix: crop tightly to cover only the digits.

Mistaking the 0 written on a failed read for a real 0; the flow branches wrongly. Fix: decide with ocr_ok (and ocr_status if needed).

Pro Tips

If the number is in a specific script, set ocrScript explicitly (e.g. arabic or cyrillic); choosing the right family instead of auto noticeably boosts accuracy.

On fast-changing counters add a short WAIT before each pass; you prevent OCR from reading a half-refreshed frame and producing a wrong value.

Branch on ocr_status: in SWITCH_CASE, empty → the region is blank or misplaced, invalid → other text sits next to the number, error → check screen capture. Each failure type then gets its own clear response.

Coming soonv1.0.51A new OCR_VALUE block starts with a 10 ms Search Duration, which allows a single read, so there is no re-read when the first frame yields no number. For automatic re-reads, set Search Duration to 0 (3 reads within 750 ms) or give it a window of 750 ms or more.

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 ocr_val = nil
local ocr_raw = nil
local ocr_ok = nil
local ocr_status = nil

local _ocrText1 = ""
local _ocrReadParam1 = {ocrScript="latin", scale=1.0, mScore=0.8, engine="balanced_text"}
local _ocrReadSucceeded1 = false
local _ocrParsed1 = 0 / 0
local _ocrRefreshSucceeded1 = false
local _ocrAttempt1 = 0
local _ocrStartedAt1 = System.currentTime()
repeat
 _ocrAttempt1 = _ocrAttempt1 + 1
 if _ocrAttempt1 == 2 then
  _ocrReadParam1.scale = 1.6
 elseif _ocrAttempt1 >= 3 then
  _ocrReadParam1.scale = 2.0
 end
 if _ocrAttempt1 > 1 and Snap.clear then pcall(function() Snap.clear() end) end
 local _ocrRefreshOk1, _ocrRefreshError1 = pcall(function() Snap.screenRefresh() end)
 if not _ocrRefreshOk1 then
  local _ocrRefreshSignal1 = string.lower(tostring(_ocrRefreshError1 or ""))
  if string.find(_ocrRefreshSignal1, "compatstopexception", 1, true) or string.find(_ocrRefreshSignal1, "script durduruldu", 1, true) or string.find(_ocrRefreshSignal1, "budget_", 1, true) then
   error(_ocrRefreshError1, 0)
  end
 end
 if _ocrRefreshOk1 then
  _ocrRefreshSucceeded1 = true
  local _ocrAttemptOk__ocrReg1_1, _ocrAttemptText__ocrReg1_1 = pcall(function()
   local _ocrReg1_1 = Region(0, 0, 540, 200)
   return _ocrReg1_1:readAsString(_ocrReadParam1, "") or ""
  end)
  if not _ocrAttemptOk__ocrReg1_1 then
   local _ocrAttemptError__ocrReg1_1 = string.lower(tostring(_ocrAttemptText__ocrReg1_1 or ""))
   if string.find(_ocrAttemptError__ocrReg1_1, "compatstopexception", 1, true) or string.find(_ocrAttemptError__ocrReg1_1, "script durduruldu", 1, true) or string.find(_ocrAttemptError__ocrReg1_1, "budget_", 1, true) then
    error(_ocrAttemptText__ocrReg1_1, 0)
   end
  end
  if _ocrAttemptOk__ocrReg1_1 then
   _ocrReadSucceeded1 = true
   local _ocrCandidateText__ocrReg1_1 = tostring(_ocrAttemptText__ocrReg1_1 or "")
   local _ocrCandidateParsed__ocrReg1_1 = Num.parseOcr(_ocrCandidateText__ocrReg1_1, 0 / 0)
   if _ocrCandidateParsed__ocrReg1_1 == _ocrCandidateParsed__ocrReg1_1 or (_ocrText1:match("^%s*
quot;) and not _ocrCandidateText__ocrReg1_1:match("^%s*
quot;)) then _ocrText1 = _ocrCandidateText__ocrReg1_1 _ocrParsed1 = _ocrCandidateParsed__ocrReg1_1 end end end if not (_ocrParsed1 == _ocrParsed1) and _ocrAttempt1 < 3 and (System.currentTime() - _ocrStartedAt1) < 750 then wait(100) end until (_ocrParsed1 == _ocrParsed1) or _ocrAttempt1 >= 3 or (System.currentTime() - _ocrStartedAt1) >= 750 local _ocrReadOk1 = _ocrRefreshSucceeded1 and _ocrReadSucceeded1 ocr_raw = _ocrText1 ocr_ok = _ocrReadOk1 and (_ocrParsed1 == _ocrParsed1) if not _ocrReadOk1 then ocr_status = "error" elseif tostring(ocr_raw or ""):match("^%s*
quot;) then ocr_status = "empty" elseif not ocr_ok then ocr_status = "invalid" else ocr_status = "ok" end ocr_val = Num.parseOcr(ocr_raw, 0) if type(__mh_ocr_value_provenance) ~= "table" then __mh_ocr_value_provenance = {} end __mh_ocr_value_provenance["ocr_val"] = { ok = ocr_ok, value = ocr_val }

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.

🔎Scan Region

Keep the search close to the target. Smaller regions are faster and more stable.

🚫Exclude Region

Exclude static noise, badges, animations, or reflective areas to reduce false matches.

⏱Timeout and Scan Rate

Timeout and scan rate define whether the block acts as a single check or controlled polling step.

🎯Match Tuning

mScore, scale, and engine choice must be tuned together for theme, resolution, and rendering differences.

🧭Result Variables

OCR_VALUE writes the number it reads to its result variable (default ocr_val); TEXT writes the text it passed through its find/replace step to the Save Read Value variable (default ocr_val). In Match Variables, the score variable (0.0–1.0 confidence) and the X/Y/W/H variables carry the match confidence and position into later blocks: branch on the score with COMPARE, and in CLICK bind the coordinates to them with {x} or turn on Click on match. _lastMatch is the last match that Click on match uses; _lastOcrText is kept only for older CUSTOM_CODE scripts.

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 →