Contents

AXUIElementCopyElementAtPosition(_:_:_:_:)

Returns the accessibility object at the specified position in top-left relative screen coordinates.

Declaration

func AXUIElementCopyElementAtPosition(_ application: AXUIElement, _ x: Float, _ y: Float, _ element: UnsafeMutablePointer<AXUIElement?>) -> AXError

Parameters

  • application:

    The AXUIElementRef representing the application that contains the screen coordinates (or the system-wide accessibility object).

  • x:

    The horizontal position.

  • y:

    The vertical position.

  • element:

    On return, the accessibility object at the position specified by x and y.

Return Value

If unsuccessful, AXUIElementCopyElementAtPosition may return one of the following error codes, among others:

kAXErrorNoValue

There is no accessibility object at the specified position.

kAXErrorIllegalArgument

One or more of the arguments is an illegal value.

kAXErrorInvalidUIElement

The AXUIElementRef is invalid.

kAXErrorCannotComplete

The function cannot complete because messaging has failed in some way.

kAXErrorNotImplemented

The process does not fully support the accessibility API.

Discussion

This function does hit-testing based on window z-order (that is, layering). If one window is on top of another window, the returned accessibility object comes from whichever window is topmost at the specified location. Note that if the system-wide accessibility object is passed in the application parameter, the position test is not restricted to a particular application.

See Also

Miscellaneous