Could somebody explain when I pass a control's AutomationID, how the code find the correct control and invoke the supported methods? (Assume I use UIAutomation technology and write the codes in C#) And what's difference between MSAA and UIAutomation
In brief, Microsoft's UI Automation Framework represents all applications under the desktop as a visual tree of AutomationElements. You can use the UIA framework to search for items in this tree using conditions such as the one you mentioned, AutomationId.
You can then request different patterns, each allowing you to perform various actions on the control. A simple example for finding a control (let's assume it's a button and can be clicked) with the AutomationID being 'Demo' -- and then clicking it -- would
// Create the condition for searching the control
var condition = new PropertyCondition(AutomationElement.AutomationIdProperty, "Demo");
// Find the control
var demoElement = AutomationElement.FindFirst(TreeScope.Descendants, condition);
// Request an InvokePattern object instance
var invokePattern = demoElement.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
// Call the click method on the InvokePattern instance
As for your last question, MSAA is the legacy technology introduced as far as Windows 95 - UIA replaces it (and contains it for legacy support).
Hi Tal, thank you very much for your reply. I think I have to re-organize my questions. Actually, what I really want to know is when I launch an application, how windows know the application is launched and add the application's UI elements(buttons/labels/listboxes...) under
the desktop which is the root node of the element tree. And which component/service is managing the element tree?