I need to get fullDescription property of a UI element using get_CurrentFullDescription method of UIAutomation library of c windows.
Issue is I have element as IUIAutomationElement instead of IUIAutomationElement6, get_CurrentFullDescription can only be invoked on element with IUIAutomationElement6 type.
How can I convert IUIAutomationElement to IUIAutomationElement6?
I am using HandlePropertyChangedEvent method to listen on changes in UI, which returns:
HRESULT HandlePropertyChangedEvent(
[in] IUIAutomationElement *sender,
[in] PROPERTYID propertyId,
[in] VARIANT newValue
);
Here, I need to access FullDescription property of sender element coming from HandlePropertyChangedEvent function.
CodePudding user response:
@IInspectable mentioned QueryInterface hint in comments, based on that here is answer:
CComPtr<IUIAutomationElement> pElement;
// Code to initialize pElement goes here
CComPtr<IUIAutomationElement6> pElement6;
HRESULT hr = pElement->QueryInterface(&pElement6);
if (SUCCEEDED(hr))
{
// Use the pElement6 object here
}
