I am trying to use MS UIAutomation in my Rust windows project. I've found out your project here: How to install the uiautomationcore-sys crate // Lib.rs
But unforcedly, I cannot find out any documentation of how to use it.
My goal is to get positions of taskbar buttons at the Windows taskbar. Something like at the PowerToys project:
winrt::com_ptr<IUIAutomationElementArray> elements;
winrt::com_ptr<IUIAutomationElement> child;
...
if (VARIANT var_rect; child->GetCurrentPropertyValue(UIA_BoundingRectanglePropertyId, &var_rect) >= 0) {
if (var_rect.vt == (VT_R8 | VT_ARRAY)) {
LONG pos;
double value;
pos = 0; SafeArrayGetElement(var_rect.parray, &pos, &value);
button.x = (long)value;
pos = 1; SafeArrayGetElement(var_rect.parray, &pos, &value);
button.y = (long)value;
pos = 2; SafeArrayGetElement(var_rect.parray, &pos, &value);
button.width = (long)value;
pos = 3; SafeArrayGetElement(var_rect.parray, &pos, &value);
button.height = (long)value;
}
Or in the FastWindowSwitcher project:
VARIANT propertyValue = { 0 };
HRESULT hr = p_element.GetCurrentPropertyValue(UIA_BoundingRectanglePropertyId, &propertyValue);
...
double* data = nullptr;
hr = SafeArrayAccessData(propertyValue.parray, (void**)&data);
...
QRect rectangle(data[0], data[1], data[2], data[3]);
...
return rectangle;
Maybe there is a better way to do it now?
Thanks,
Yura