Ready-to-use Code ExampleSettingDialogEditText

Dialog: Text Input

Creates a dialog with text input fields using Setting.builder(). EditText fields collect parameters like delay time and target name; values are read with Setting.get().

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: text input
-- Ask the user for parameters with Setting.builder()

local cfg = Setting.builder()
cfg:setTitle("Macro settings")

cfg:add("delay", EditText("500", 1, "Delay (ms)"))
cfg:add("repeat", EditText("10", 1, "Repeat count"))
cfg:add("target", EditText("ok_button", 1, "Target image name"))

Setting.setDialog(cfg:build())
Setting.show()

-- Read the values (Setting.get takes the key and a default, with a dot)
local delay = tonumber(Setting.get("delay", "500")) or 500
local repeatCount = tonumber(Setting.get("repeat", "10")) or 10
local target = Setting.get("target", "ok_button")

toast("Delay: " .. delay .. " ms, repeat: " .. repeatCount)

-- Use the values
for i = 1, repeatCount do
  Snap.screenRefresh()
  local match = Region():find(Asset.image(target))
  if match then click(match) end
  wait(delay)
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.