Ready-to-use Code ExampleSettingDialogRadioGroup

Dialog: Radio Group

Uses RadioGroup to let the user pick one option from several. The initial choice is a 0-based index; the result is the selected option text, not an index.

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: radio group

local cfg = Setting.builder()
cfg:setTitle("Mode")

cfg:add("speed", RadioGroup({ "Slow", "Normal", "Fast", "Very fast" }, 1))
cfg:add("area", RadioGroup({ "Full screen", "Top half", "Bottom half", "Center" }, 0))

local result = cfg:build():show()
if type(result) ~= "table" then return end

-- Selection controls return the selected option text.
local speed = result["speed"] or "Normal"
local area = result["area"] or "Full screen"

-- Pick a delay for the speed
local delays = { Slow = 1000, Normal = 500, Fast = 200, ["Very fast"] = 50 }
local delay = delays[speed] or 500

-- Pick a Region for the area
local screen = Region()
local sw = screen:getW()
local sh = screen:getH()
local areas = {
  ["Full screen"] = { 0, 0, sw, sh },
  ["Top half"] = { 0, 0, sw, math.floor(sh / 2) },
  ["Bottom half"] = { 0, math.floor(sh / 2), sw, sh - math.floor(sh / 2) },
  ["Center"] = { math.floor(sw * 0.18), math.floor(sh * 0.20), math.floor(sw * 0.64), math.floor(sh * 0.58) },
}
local b = areas[area] or areas["Full screen"]
local region = Region(b[1], b[2], b[3], b[4])

toast("Mode: " .. speed .. ", delay: " .. delay .. " ms")

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.