Ready-to-use Code ExampleSettingDialogTabLayoutEditTextCheckboxRadioGroup

Dialog: Tabbed Settings Panel

Creates an advanced settings panel with multiple tabs using TabLayout. Each tab can combine different components (EditText, Checkbox, RadioGroup). Ideal for complex macros.

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.

-- 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

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.