Can UI Automation be disabled for an entire WPF 4.0 app?

前端 未结 5 1114
死守一世寂寞
死守一世寂寞 2021-01-30 09:47

We are developing a WPF 4.0 application for internal use.
On some clients, we are experiencing huge performance issues due to UI automation (these clients have software i

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 10:00

    Try some cargo-cult programming:

    WindowInteropHelper helper = new WindowInteropHelper(mainWindow);
            AutomationElement mainWindowAutomationElement = AutomationElement.FromHandle(helper.Handle);
            Automation.Automation.AddStructureChangedEventHandler(mainWindowAutomationElement, TreeScope.Descendants, AutomationFix);
    
          void AutomationFix(object sender, StructureChangedEventArgs e)
      {
                AutomationElement element = sender as AutomationElement;
        Automation.Condition condition = new PropertyCondition(AutomationElement.NameProperty, "!!");
        AutomationElement automationElement = element.FindFirst(TreeScope.Children, condition);
      }
    

提交回复
热议问题