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