public void spy()
        {
            var curtime = DateTime.Now;

            try
            {
                log.Info("BEGIN SPY FROM HIGHLIGHT FORM");
                Process targetProcess = WindowInteraction.GetProcess(ProcessName);
                //WindowInteraction.FocusWindow(targetProcess);
                App         = Gu.Wpf.UiAutomation.Application.Attach(targetProcess.Id);
                MainWindow  = App.MainWindow;
                ElementList = MainWindow.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.FrameworkIdProperty, "WPF"));
                dataGridView1.Rows.Clear();
                dataGridView1.AllowUserToAddRows = true;

                SpyObjectList = new SpyObject[ElementList.Count];
                int SpyObjectIndex = 0;

                //comboBox1.Enabled = false;

                for (int i = 0; i < ElementList.Count; i++)
                {
                    SpyObjectList[SpyObjectIndex]       = new SpyObject();
                    SpyObjectList[SpyObjectIndex].index = SpyObjectIndex;
                    if (ElementList[i].AutomationId == "" && SpyObjectIndex - 1 > 0 && ElementList[i - 1].Name != "" && ElementList[i].Name == "")
                    {
                        SpyObjectList[SpyObjectIndex].automationId = (ElementList[i - 1].Name + "_" + ElementList[i].ClassName).Replace(" ", "_").Replace(":", "");
                    }
                    else
                    {
                        SpyObjectList[SpyObjectIndex].automationId = ElementList[i].AutomationId;
                    }
                    SpyObjectList[SpyObjectIndex].name = ElementList[i].Name;
                    SpyObjectList[SpyObjectIndex].type = ElementList[i].ClassName;
                    DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[i].Clone();
                    row.Cells[0].Value = SpyObjectList[SpyObjectIndex].index;
                    row.Cells[1].Value = SpyObjectList[SpyObjectIndex].automationId;
                    row.Cells[2].Value = SpyObjectList[SpyObjectIndex].name;
                    row.Cells[3].Value = SpyObjectList[SpyObjectIndex].type;
                    dataGridView1.Rows.Add(row);
                    SpyObjectIndex++;
                }
                log.Info("SPY DONE OF HIGHLIGHT");



                dataGridView1.AllowUserToAddRows = false;
            }
            catch (Exception ex)
            {
                log.Error("ERROR CODE: " + ex.HResult + "  -----  " + "detail: " + ex.Message);
            }
        }
        public void highlight(int objectID)
        {
            var curtime = DateTime.Now;

            try
            {
                log.Info("BEGIN HIGHLIGHT");
                Process targetProcess = WindowInteraction.GetProcess(ProcessName);
                GrabAUT.GetMainWindow();
                ElementList = GrabAUT.SearchbyFramework("WPF");

                SpyObjectList = new SpyObject[ElementList.Count];
                int SpyObjectIndex = 0;
                for (int i = 0; i < ElementList.Count; i++)
                {
                    SpyObjectList[SpyObjectIndex]       = new SpyObject();
                    SpyObjectList[SpyObjectIndex].index = SpyObjectIndex;
                    if (ElementList[i].AutomationId == "" && SpyObjectIndex - 1 > 0 && ElementList[i - 1].Name != "" && ElementList[i].Name == "")
                    {
                        SpyObjectList[SpyObjectIndex].automationId = (ElementList[i - 1].Name + "_" + ElementList[i].ClassName).Replace(" ", "_").Replace(":", "");
                    }
                    else
                    {
                        SpyObjectList[SpyObjectIndex].automationId = ElementList[i].AutomationId;
                    }
                    SpyObjectList[SpyObjectIndex].name = ElementList[i].Name;
                    SpyObjectList[SpyObjectIndex].type = ElementList[i].ClassName;

                    if (SpyObjectList[SpyObjectIndex].index == objectID)
                    {
                        for (int a = 0; a < 3; a++)
                        {
                            ElementList[SpyObjectList[SpyObjectIndex].index].DrawHighlight(true, Color.Red, TimeSpan.FromSeconds(1));
                        }
                    }

                    SpyObjectIndex++;
                }
                log.Info("DONE HIGHLIGHT");
            }
            catch (Exception ex)
            {
                log.Error("ERROR CODE: " + ex.HResult + "  -----  " + "detail: " + ex.Message);
            }
        }
        public void highlight(int objectID)
        {
            var curtime = DateTime.Now;

            try
            {
                log.Info("BEGIN HIGHLIGHT");
                Process targetProcess = WindowInteraction.GetProcess(ProcessName);

                App           = Gu.Wpf.UiAutomation.Application.Attach(targetProcess.Id);
                MainWindow    = App.MainWindow;
                ElementList   = MainWindow.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.FrameworkIdProperty, "WPF"));
                SpyObjectList = new SpyObject[ElementList.Count];
                int SpyObjectIndex = 0;
                for (int i = 0; i < ElementList.Count; i++)
                {
                    SpyObjectList[SpyObjectIndex]       = new SpyObject();
                    SpyObjectList[SpyObjectIndex].index = SpyObjectIndex;
                    if (ElementList[i].AutomationId == "" && SpyObjectIndex - 1 > 0 && ElementList[i - 1].Name != "" && ElementList[i].Name == "")
                    {
                        SpyObjectList[SpyObjectIndex].automationId = (ElementList[i - 1].Name + "_" + ElementList[i].ClassName).Replace(" ", "_").Replace(":", "");
                    }
                    else
                    {
                        SpyObjectList[SpyObjectIndex].automationId = ElementList[i].AutomationId;
                    }
                    SpyObjectList[SpyObjectIndex].name = ElementList[i].Name;
                    SpyObjectList[SpyObjectIndex].type = ElementList[i].ClassName;


                    if (SpyObjectList[SpyObjectIndex].index == objectID)
                    {
                        ElementList[SpyObjectList[SpyObjectIndex].index].DrawHighlight(true, Color.Red, TimeSpan.FromSeconds(2));
                    }

                    SpyObjectIndex++;
                }
                log.Info("DONE HIGHLIGHT");
            }
            catch (Exception ex)
            {
                log.Error("ERROR CODE: " + ex.HResult + "  -----  " + "detail: " + ex.Message);
            }
        }
        public static void DoCapture(string Proc)
        {
            var curtime = DateTime.Now;

            var path      = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var imagePath = path + @"\Botsina\SpyObjects\";

            System.IO.FileInfo file = new System.IO.FileInfo(imagePath);

            if (file.Directory.Exists)
            {
                DirectoryInfo dir = new DirectoryInfo(imagePath);

                foreach (FileInfo fi in dir.GetFiles())
                {
                    fi.Delete();
                }
            }
            else
            {
                file.Directory.Create();
            }

            try
            {
                //this.Hide();

                log.Info("BEGIN CAPTURE TO FILE");

                file.Directory.Create();

                Process targetProcess = WindowInteraction.GetProcess(Proc);

                App           = Gu.Wpf.UiAutomation.Application.Attach(targetProcess.Id);
                MainWindow    = App.MainWindow;
                ElementList   = MainWindow.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.FrameworkIdProperty, "WPF"));
                SpyObjectList = new SpyObject[ElementList.Count];
                int SpyObjectIndex = 0;

                SendKeys.Send("{PRTSC}");

                Image img = Clipboard.GetImage();

                for (int i = 0; i < ElementList.Count; i++)
                {
                    SpyObjectList[SpyObjectIndex]       = new SpyObject();
                    SpyObjectList[SpyObjectIndex].index = SpyObjectIndex;
                    if (ElementList[i].AutomationId == "" && SpyObjectIndex - 1 > 0 && ElementList[i - 1].Name != "" && ElementList[i].Name == "")
                    {
                        SpyObjectList[SpyObjectIndex].automationId = (ElementList[i - 1].Name + "_" + ElementList[i].ClassName).Replace(" ", "_").Replace(":", "");
                    }
                    else
                    {
                        SpyObjectList[SpyObjectIndex].automationId = ElementList[i].AutomationId;
                    }
                    SpyObjectList[SpyObjectIndex].name = ElementList[i].Name;
                    SpyObjectList[SpyObjectIndex].type = ElementList[i].ClassName;

                    if ((SpyObjectList[SpyObjectIndex].type == "ComboBox" ||
                         SpyObjectList[SpyObjectIndex].type == "ComboBoxEdit" ||
                         SpyObjectList[SpyObjectIndex].type == "DataGrid" ||
                         SpyObjectList[SpyObjectIndex].type == "TextBox" ||
                         SpyObjectList[SpyObjectIndex].type == "Button" ||
                         SpyObjectList[SpyObjectIndex].type == "RadioButton" ||
                         SpyObjectList[SpyObjectIndex].type == "AutoCompleteCombobox")

                        && SpyObjectList[SpyObjectIndex].automationId.Contains("PART") != true)
                    {
                        if (ElementList[SpyObjectIndex].Bounds.IsEmpty == false && ElementList[SpyObjectIndex].IsOffscreen == false)
                        {
                            ElementList[SpyObjectIndex].CaptureToFile(imagePath + SpyObjectIndex + ".png");
                            log.Info(ElementList[SpyObjectIndex].ClassName);
                        }
                    }

                    SpyObjectIndex++;
                }
                img.Save(imagePath + "thisScreen" + ".png");
                log.Info("DONE CAPTURE TO FILE");

                //this.Show();
            }
            catch (Exception ex)
            {
                log.Error("ERROR CODE: " + ex.HResult + "  -----  " + "detail: " + ex.Message);
                //this.Show();
            }
        }