getLastChildElement method

IUIAutomationElement? getLastChildElement(
  1. IUIAutomationElement? element
)

Retrieves the last child element of the specified UI Automation element.

Throws a WindowsException on failure.

To learn more, see learn.microsoft.com/windows/win32/api/uiautomationclient/nf-uiautomationclient-iuiautomationtreewalker-getlastchildelement.

Implementation

IUIAutomationElement? getLastChildElement(IUIAutomationElement? element) {
  final last = adaptiveCalloc<VTablePointer>();
  final hr$ = HRESULT(
    _GetLastChildElementFn(ptr, element?.ptr ?? nullptr, last),
  );
  if (hr$.isError) {
    free(last);
    throw WindowsException(hr$);
  }
  final result$ = last.value;
  free(last);
  if (result$.isNull) return null;
  return .new(result$);
}