Skip to main content

MatchResult:getText()

Returns the label or text associated with the match.

Description

The getText() method returns a string label associated with the matched result. This is particularly useful when:

  • Performing text-based searches (OCR) where the recognized text is returned
  • Working with labeled templates where you want to identify which template was matched

If no label is associated with the match, this method returns an empty string.

Signature

getText(): string

Returns

string - The label or text associated with the match, or an empty string if none.

Example

-- Example with OCR text search
local result = Screen:find("hello World", FinderParams():setDetectionType("TEXT"))
if result then
local text = result:getText()
toast("Found text: " .. text)
end

-- Example checking for specific text
local result = Screen:find("submit", FinderParams():setDetectionType("TEXT"))
if result then
local label = result:getText()
if label == "submit" then
toast("Found submit button!")
end
end