MatchResult:getRegion()
Returns the matched region as a Region object.
Description
The getRegion() method returns a Region object that represents the rectangular area where the match was found. This region includes the position (X, Y) of the top-left corner and the dimensions (width, height) of the matched area.
The returned Region can be used to:
- Perform further searches within the matched area
- Capture a screenshot of just the matched region
- Define a sub-region for other operations
Signature
getRegion(): Region
Returns
Region - A Region object representing the rectangular bounds of the matched area.
Example
local result = Screen:find("container.png")
if result then
local region = result:getRegion()
toast("Region: X=" .. region:getX() .. ", Y=" .. region:getY())
toast("Size: " .. region:getWidth() .. "x" .. region:getHeight())
-- Search within the matched region for faster matching
local innerResult = region:find("container.png")
if innerResult then
toast("Found container.png inside region!")
end
end