A bit late answer, but I wanted to fix the answer selected here. Yes, it is true that the VS provided by the COM shell may use a different UIAutomationClient.dll, and that the use of native code will be different from the managed code when calling the UIAutomation methods, but, nevertheless, the question asked here is another problem. (By the way, you can use the COM shell from managed code to call the correct version of the UIAutomation DLL, which will solve problems such as "inspect.exe finds, but my managed code cannot.").
I also ran into the problem posed here (mine: FindAll (TreeScope.Children, TrueCondition) did not return anything, although FindFirst () successfully returned children to the same control).
I tried using mike-z using RawViewWalker to find children, and it did a great job with this. I am writing this separate answer to say that it was not the Find * methods, but the difference between the FindAll and FindFirst methods that caused the August problem.
Update
Erratic behavior seems to be the norm when it comes to MS tools. The reason for this update is that I ran into a similar problem with my tlbimp.exe'd RCW for uia using C #, and this time I wrote direct equivalent C code, and, to my surprise, it worked fine while C # code refused to work anyway, trying to find simple OpenFileDialog controls, and then another control in the main form. The only difference between the two worlds is the mysterious magic of MC RCW. I'm not sure if this is the way marshaling is handled by automatically generated COM wrappers (tlbimp) or something else. But the attribute [ComConversionLoss], which appears for the created interface, does not suit me. In any case, I am now considering the possibility of manually creating a COM interface or converting the entire project into a native environment.
source share