Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 闪光灯中的自动元件_C#_Flash_Inspect_Automationelement - Fatal编程技术网

C# 闪光灯中的自动元件

C# 闪光灯中的自动元件,c#,flash,inspect,automationelement,C#,Flash,Inspect,Automationelement,我使用AutomationElement类在浏览器(firefox)中的flash应用程序(BigBlueButton,我正在测试)中查找聊天。只要没有新消息出现,它似乎就可以工作。每次收到新消息时,UI都会更新AutomationElement,其中a)找不到聊天室或b)AutomationElement描述聊天室不包含任何消息。 在新消息到达之前,它似乎起作用了。我可以访问这些消息 到目前为止,我的代码是: private void getLastChatMessage(){

我使用AutomationElement类在浏览器(firefox)中的flash应用程序(BigBlueButton,我正在测试)中查找聊天。只要没有新消息出现,它似乎就可以工作。每次收到新消息时,UI都会更新AutomationElement,其中a)找不到聊天室或b)AutomationElement描述聊天室不包含任何消息。 在新消息到达之前,它似乎起作用了。我可以访问这些消息

到目前为止,我的代码是:

    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 > 0)
    {
        String lastMessage = chatMessages[chatMessages.Count - 1].Current.Name;
        System.Console.WriteLine("lastMessage: {0}", lastMessage);
    }
    else
    {
        System.Console.WriteLine("chatMessages.Count <= 0");
    }
}
private void getLastChatMessage(){
System.Diagnostics.Process[]p=System.Diagnostics.Process.getProcessByName(“Firefox”);
AutomationElement au=AutomationElement.FromHandle(p[0].MainWindowHandle);
PropertyCondition chatCond=新的PropertyCondition(AutomationElement.NameProperty,“消息框”);
条件listCond=新属性条件(AutomationElement.ControlTypeProperty,ControlType.List);
AndCondition listAChatCond=新AndCondition(listCond,chatCond);
AutomationElement chatArea=au.FindFirst(TreeScope.子孙,listAChatCond);
if(chatArea==null)
{
System.Console.WriteLine(“chatArea==null”);
回来
}
System.Console.WriteLine(“名称:{0}”,chatArea.Current.name);
PropertyCondition messageCond=新的PropertyCondition(AutomationElement.IsEnabledProperty,true);
AutomationElementCollection chatMessages=chatArea.FindAll(TreeScope.Children,messageCond);
如果(chatMessages.Count>0)
{
字符串lastMessage=chatMessages[chatMessages.Count-1].Current.Name;
System.Console.WriteLine(“lastMessage:{0}”,lastMessage);
}
其他的
{
System.Console.WriteLine(“chatMessages.Count