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.
-- Dialog: tabbed settings
local cfg = Setting.builder()
cfg:setTitle("Advanced settings")
-- Every tab owns an explicit set of field keys.
local tabs = TabLayout({}, 0):saveSelected(false)
tabs:tab("General", { "delay", "limit", "mode" }, {}, true)
tabs:tab("Scan", { "score", "scanRate", "multi" }, {}, true)
tabs:tab("Alerts", { "vibrate", "sound", "keepLog", "logFile" }, {}, true)
cfg:add("tab", tabs)
-- General tab
cfg:add("delay", EditText("500", 1, "Main delay (ms)"))
cfg:add("limit", EditText("100", 1, "Maximum repeats"))
cfg:add("mode", RadioGroup({ "Loop", "Once", "Scheduled" }, 0))
-- Scan tab
cfg:add("score", EditText("0.80", 1, "Match score (0-1)"))
cfg:add("scanRate", EditText("5", 1, "Scans per second (1-30)"))
cfg:add("multi", Checkbox(false, "Search for several targets"))
-- Alerts tab
cfg:add("vibrate", Checkbox(true, "Vibrate"))
cfg:add("sound", Checkbox(false, "Sound alert"))
cfg:add("keepLog", Checkbox(true, "Keep a log file"))
cfg:add("logFile", EditText("macro_log.txt", 1, "Log file name"))
local result = cfg:build():show()
if type(result) ~= "table" then return end
-- Read every value
local delay = tonumber(result["delay"]) or 500
local limit = tonumber(result["limit"]) or 100
local mode = result["mode"] or "Loop"
-- FindParam keeps mScore inside 0-1 and sRate inside 1-30 scans per second
local score = math.min(math.max(tonumber(result["score"]) or 0.80, 0), 1)
local scanRate = math.min(math.max(math.floor(tonumber(result["scanRate"]) or 5), 1), 30)
local vibrate = result["vibrate"] == true
local keepLog = result["keepLog"] == true
local logFile = result["logFile"] or "macro_log.txt"
toast("Settings loaded: " .. delay .. " ms, " .. limit .. " repeats")
if keepLog then
File.write(logFile, "Macro started - mode: " .. mode .. "\n")
end
if vibrate then
System.vibrate(100)
end