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.
-- Floating debug panel
Panel.show()
Panel.setOpacity(0.85)
-- Restore the saved position
local savedX = KV.getNumber("panel_x", 100)
local savedY = KV.getNumber("panel_y", 200)
Panel.setPosition(savedX, savedY)
for iteration = 1, 50 do
-- Stop when the user closed the panel
if not Panel.isAvailable() then
toast("Panel closed, stopping")
break
end
-- Save the position when the user moved the panel
local currentX = Panel.getX()
local currentY = Panel.getY()
if currentX ~= savedX or currentY ~= savedY then
KV.set("panel_x", currentX)
KV.set("panel_y", currentY)
savedX, savedY = currentX, currentY
end
-- Scan only while the panel is visible
if Panel.isVisible() then
-- ... your scan logic ...
end
wait(500)
end
Panel.hide()