C# UI Automation从IE HTML输入文本字段返回空白AutomationId

C# UI Automation从IE HTML输入文本字段返回空白AutomationId,c#,internet-explorer,microsoft-ui-automation,C#,Internet Explorer,Microsoft Ui Automation,我使用“AddAutomationFocusChangedEventHandler”来捕获IE中的输入字段何时被关注。当AutomationElement被传回时,AutomationId始终为空 在Inspect.exe中查看字段时,它会将HTML输入字段id值显示为AutomationId。我不确定UI自动化为什么不将这个值返回给我。我的应用程序和IE在同一用户下运行 UI自动化是否存在固有的问题 Automation.AddAutomationFocusChangedEve

我使用“AddAutomationFocusChangedEventHandler”来捕获IE中的输入字段何时被关注。当AutomationElement被传回时,AutomationId始终为空

在Inspect.exe中查看字段时,它会将HTML输入字段id值显示为AutomationId。我不确定UI自动化为什么不将这个值返回给我。我的应用程序和IE在同一用户下运行

UI自动化是否存在固有的问题

        Automation.AddAutomationFocusChangedEventHandler(OnFocusChangedHandler);


        private void OnFocusChangedHandler(object src, AutomationFocusChangedEventArgs args)
        {
            Console.WriteLine("Focus changed!");

            AutomationElement element = null;

            try
            {
                element = src as AutomationElement;
            }
            catch { }

            if (element != null)
            {                    
                    string name = element.Current.Name;
                    string id2 = element.Current.AutomationId;

                    int processId = element.Current.ProcessId;

                    InsertTextUsingUIAutomation(element, id2);

                    using (Process process = Process.GetProcessById(processId))
                    {
                        Console.WriteLine("  Name: {0}, Id: {1}, Process: {2}", name, id2, process.ProcessName);
                    }
                }
            }
        }

有同样的问题。Inspect.exe会看到AutomationId。DotNet UIAutomation看不到。