I observe an illogical behavior of TreeWalker for filtered trees. Let us assume that we try to find all buttons in some application window using walker. So we create a walker with the corresponding condition, something like:
VARIANT prop; prop.vt = VT_I4; prop.lVal = UIA_ButtonControlTypeId; CComPtr<IUIAutomationCondition> type_condition_ptr; automation_ptr->CreatePropertyCondition(UIA_ControlTypePropertyId, prop, &type_condition_ptr); CComPtr<IUIAutomationTreeWalker> walker_ptr; automation_ptr->CreateTreeWalker(type_condition_ptr, &walker_ptr);
And then walk the sub-tree for app's window (wnd_ptr):
IUIAutomationElement* child_ptr; walker_ptr->GetFirstChildElement(wnd_ptr, &child_ptr); while (child_ptr != NULL) { walker_ptr->GetNextSiblingElement(child_ptr, &child_ptr); }
On practice GetNextSiblingElement() returns not only buttons of wnd_ptr's subtree, but buttons from some other (not all) apps sub-trees.
It seems that the hierarchical structure of UI tree is not counted. Is that intended logic or bug? If it is the intended logicthen how to use the walker with the condition filter for sub-trees?