title: AutomationElement in flash
body: <p>I'm using the AutomationElement-Class to find a chat in a flash application (BigBlueButton, <a href="http://demo.bigbluebutton.org" rel="nofollow">http://demo.bigbluebutton.org</a>, I'm testing it there) in a browser (firefox). It seems to work as long as no new messages appear. Every time a new Message comes in, the UI updates the AutomationElement which a) can't find the chat or b) the AutomationElement describes the chat contains no messages.
  Before a new message arrives it seems to work. I can access the messages.</p>
  
  <p>My Code so far:</p>
  
  <pre><code>    private void getLastChatMessage(){
      System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("Firefox");
      AutomationElement au = AutomationElement.FromHandle(p[0].MainWindowHandle);
  
      PropertyCondition chatCond = new PropertyCondition(AutomationElement.NameProperty, "Message Box");
      Condition listCond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.List);
      AndCondition listAChatCond = new AndCondition(listCond, chatCond);
  
      AutomationElement chatArea = au.FindFirst(TreeScope.Descendants, listAChatCond);
      if (chatArea == null)
      {
          System.Console.WriteLine("chatArea == null");
          return;
      }
      System.Console.WriteLine("name: {0}", chatArea.Current.Name);
      PropertyCondition messageCond = new PropertyCondition(AutomationElement.IsEnabledProperty, true);
      AutomationElementCollection chatMessages = chatArea.FindAll(TreeScope.Children, messageCond);
      if (chatMessages.Count &gt; 0)
      {
          String lastMessage = chatMessages[chatMessages.Count - 1].Current.Name;
          System.Console.WriteLine("lastMessage: {0}", lastMessage);
      }
      else
      {
          System.Console.WriteLine("chatMessages.Count &lt;= 0");
      }
  }
  </code></pre>
  
  <p>Has anybody an idea how to get the chat after a UI update?</p>
  
  <p>I tested it with the MS inspect-tool (<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd318521%28v=vs.85%29.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/desktop/dd318521%28v=vs.85%29.aspx</a>). If a new chat message comes in and I refresh the tree I also didn't see the new message. The same happens if I'm testing this with the internet explorer. If I'm collapsing the whole tree of the application and the I go again to the messages I see the new message. Sometimes I can't see the whole tree after I have collapsed the tree. Then I have to restart the browser.
  Does anybody know how I can get the new message whit my program? How (and why) does the inspect-tool get better results?</p>
  
  <p>Greetings</p>