public WindowsSelectorItem(AutomationElement element, bool isRoot, int IndexInParent = -1)
 {
     this.Element = new UIElement(element);
     Properties   = new ObservableCollection <SelectorItemProperty>();
     if (isRoot)
     {
         var w = element.AsWindow();
         if (element.Properties.ProcessId.IsSupported)
         {
             var info = element.GetProcessInfo();
             if (info.IsImmersiveProcess)
             {
                 Properties.Add(new SelectorItemProperty("isImmersiveProcess", info.IsImmersiveProcess.ToString()));
                 Properties.Add(new SelectorItemProperty("applicationUserModelId", info.ApplicationUserModelId));
             }
             else
             {
                 if (info.Filename.ToLower().Contains("system32\\conhost.exe"))
                 {
                     info.Filename = "%windir%\\system32\\cmd.exe";
                 }
                 Properties.Add(new SelectorItemProperty("filename", info.Filename));
                 Properties.Add(new SelectorItemProperty("processname", info.ProcessName));
                 Properties.Add(new SelectorItemProperty("arguments", info.Arguments));
             }
             Properties.Add(new SelectorItemProperty("Selector", "Windows"));
             Properties.Add(new SelectorItemProperty("search_descendants", PluginConfig.search_descendants.ToString()));
         }
         foreach (var p in Properties)
         {
             p.Enabled    = true;
             p.canDisable = false;
         }
         ;
     }
     else
     {
         try
         {
             if (element.Properties.Name.IsSupported && !string.IsNullOrEmpty(element.Properties.Name.Value))
             {
                 Properties.Add(new SelectorItemProperty("Name", element.Properties.Name.Value));
             }
             if (element.Properties.ClassName.IsSupported && !string.IsNullOrEmpty(element.Properties.ClassName))
             {
                 Properties.Add(new SelectorItemProperty("ClassName", element.Properties.ClassName.Value));
             }
             if (element.Properties.ControlType.IsSupported && !string.IsNullOrEmpty(element.Properties.ControlType.Value.ToString()))
             {
                 if (element.Properties.ControlType.Value != FlaUI.Core.Definitions.ControlType.Unknown)
                 {
                     Properties.Add(new SelectorItemProperty("ControlType", element.Properties.ControlType.Value.ToString()));
                 }
             }
             if (element.Properties.AutomationId.IsSupported && !string.IsNullOrEmpty(element.Properties.AutomationId))
             {
                 Properties.Add(new SelectorItemProperty("AutomationId", element.Properties.AutomationId.Value));
             }
             if (element.Properties.FrameworkId.IsSupported && !string.IsNullOrEmpty(element.Properties.FrameworkId))
             {
                 Properties.Add(new SelectorItemProperty("FrameworkId", element.Properties.FrameworkId.Value));
             }
             if (IndexInParent > -1)
             {
                 Properties.Add(new SelectorItemProperty("IndexInParent", IndexInParent.ToString()));
             }
         }
         catch (Exception)
         {
         }
         //Enabled = (Properties.Count > 1);
         //canDisable = true;
         if (Properties.Count == 0)
         {
             try
             {
                 var c = element.Properties.ControlType.ValueOrDefault;
                 if (c.ToString() != "Unknown")
                 {
                     Properties.Add(new SelectorItemProperty("ControlType", c.ToString()));
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
         foreach (var p in Properties)
         {
             p.Enabled    = true;
             p.canDisable = (Properties.Count > 1);
         }
         ;
         Enabled    = true;
         canDisable = true;
     }
     foreach (var p in Properties)
     {
         p.PropertyChanged += (sender, e) =>
         {
             OnPropertyChanged("Displayname");
             OnPropertyChanged("json");
         }
     }
     ;
 }
Exemple #2
0
 public WindowsSelectorItem(AutomationElement element, bool isRoot, SelectorItem rootselectoritem, int IndexInParent = -1)
 {
     this.Element = new UIElement(element);
     Properties   = new ObservableCollection <SelectorItemProperty>();
     if (isRoot)
     {
         var w = element.AsWindow();
         if (element.Properties.ProcessId.IsSupported)
         {
             var info = element.GetProcessInfo();
             if (info.IsImmersiveProcess)
             {
                 Properties.Add(new SelectorItemProperty("isImmersiveProcess", info.IsImmersiveProcess.ToString()));
                 Properties.Add(new SelectorItemProperty("applicationUserModelId", info.ApplicationUserModelId));
             }
             else
             {
                 if (info.Filename.ToLower().Contains("system32\\conhost.exe"))
                 {
                     info.Filename = "%windir%\\system32\\cmd.exe";
                 }
                 Properties.Add(new SelectorItemProperty("filename", info.Filename));
                 Properties.Add(new SelectorItemProperty("processname", info.ProcessName));
                 Properties.Add(new SelectorItemProperty("arguments", info.Arguments));
             }
             Properties.Add(new SelectorItemProperty("Selector", "Windows"));
             Properties.Add(new SelectorItemProperty("search_descendants", PluginConfig.search_descendants.ToString()));
             Properties.Add(new SelectorItemProperty("mouse_over_search", PluginConfig.try_mouse_over_search.ToString()));
         }
         foreach (var p in Properties)
         {
             p.Enabled    = true;
             p.canDisable = false;
         }
         ;
     }
     else
     {
         bool isAx = false;
         if (rootselectoritem != null)
         {
             var processname = "";
             if (!string.IsNullOrEmpty(rootselectoritem.processname()))
             {
                 processname = rootselectoritem.processname().ToLower();
             }
             if (processname == "ax32.exe" || processname == "ax32")
             {
                 isAx = true;
             }
         }
         try
         {
             var classname = "";
             //AxChildFrame
             if (element.Properties.ClassName.IsSupported && !string.IsNullOrEmpty(element.Properties.ClassName))
             {
                 classname = element.Properties.ClassName.Value;
                 Properties.Add(new SelectorItemProperty("ClassName", classname));
             }
             if (element.Properties.Name.IsSupported && !string.IsNullOrEmpty(element.Properties.Name.Value))
             {
                 var name = element.Properties.Name.Value;
                 if (classname == "AxChildFrame" || classname == "AxPopupFrame")
                 {
                     name = name.Substring(0, 14) + "*";
                 }
                 if (classname == "AxMainFrame" && name.IndexOf("‎‪Session ID‬") > 0)
                 {
                     name = name.Substring(0, name.IndexOf("‎‪Session ID‬") + 10) + "*";
                 }
                 Properties.Add(new SelectorItemProperty("Name", name));
             }
             if (element.Properties.ControlType.IsSupported && !string.IsNullOrEmpty(element.Properties.ControlType.Value.ToString()))
             {
                 if (element.Properties.ControlType.Value != FlaUI.Core.Definitions.ControlType.Unknown)
                 {
                     Properties.Add(new SelectorItemProperty("ControlType", element.Properties.ControlType.Value.ToString()));
                 }
             }
             if (element.Properties.AutomationId.IsSupported && !string.IsNullOrEmpty(element.Properties.AutomationId) && !isAx)
             {
                 Properties.Add(new SelectorItemProperty("AutomationId", element.Properties.AutomationId.Value));
             }
             if (element.Properties.FrameworkId.IsSupported && !string.IsNullOrEmpty(element.Properties.FrameworkId))
             {
                 Properties.Add(new SelectorItemProperty("FrameworkId", element.Properties.FrameworkId.Value));
             }
             if (IndexInParent > -1)
             {
                 Properties.Add(new SelectorItemProperty("IndexInParent", IndexInParent.ToString()));
             }
         }
         catch (Exception)
         {
         }
         //Enabled = (Properties.Count > 1);
         //canDisable = true;
         if (Properties.Count == 0)
         {
             try
             {
                 var c = element.Properties.ControlType.ValueOrDefault;
                 if (c.ToString() != "Unknown")
                 {
                     Properties.Add(new SelectorItemProperty("ControlType", c.ToString()));
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
         foreach (var p in Properties)
         {
             p.Enabled    = true;
             p.canDisable = (Properties.Count > 1);
         }
         ;
         Enabled    = true;
         canDisable = true;
     }
     foreach (var p in Properties)
     {
         p.PropertyChanged += (sender, e) =>
         {
             OnPropertyChanged("Displayname");
             OnPropertyChanged("json");
         }
     }
     ;
 }