Skip to main content

MatchResult:getMiddleX()

Returns the X coordinate of the center point of the matched region.

Description​

The getMiddleX() method returns the horizontal center position (X coordinate) of the matched area. This is useful when you want to perform actions like clicking on the center of the matched image or text.

The center X coordinate is calculated as: getX() + (getWidth() / 2)

Signature​

getMiddleX(): number

Returns

number - The X coordinate (in pixels) of the center point of the matched region.

Example​

local result = Screen:find("button.png")
if result then
local centerX = result:getMiddleX()
local centerY = result:getMiddleY()
-- Click on the center of the match
Screen:click(centerX, centerY)
end