public string getProcess() { try { //ListProcess = Process.GetProcesses(); index = selected_item; targetproc = ListProcess[index].ProcessName; processId = ListProcess[index].Id; GrabAUT.GetMainWindow(); T1 = new Thread(() => { MessageBox.Show("AUT: " + targetproc + " is attached successfully.", "NOTICED", MessageBoxButtons.OK, MessageBoxIcon.Information); WindowInteraction.FocusWindowNormal(thisProc); }); T1.Start(); log.Info("ATTACHED PROCESS: " + ListProcess[index].ProcessName); isAttached = true; return(ListProcess[index].ProcessName); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(null); } }
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); } }