private void GetXmlButton_Click(object sender, RoutedEventArgs e) { AutomationElement ae = (AutomationElement)((TreeViewItem)treeView1.SelectedItem).Tag; Stack <AutomationElement> automationElmements = XmlController.MakeStack(ae); String resultString = XmlController.MakeXmlFile(automationElmements, 0, null); //스택안의 구조를 xml형태로 바꾸어 string형태로 저장 resultString = resultString.Replace("><", ">\n<"); XmlBox.Text = resultString; //저장된 str을 textbox위치에 출력 }
private void MouseHook_LeftButtonDown(MouseHook.MSLLHOOKSTRUCT mouseStruct) { System.Windows.Point point = new System.Windows.Point(); point.X = mouseStruct.pt.x; point.Y = mouseStruct.pt.y; mouseHook.Uninstall(); AutomationElement ae = AutomationElement.FromPoint(point); Stack <AutomationElement> automationElements = XmlController.MakeStack(ae); String result = XmlController.MakeXmlFile(automationElements, 0, null); mainWindow.XmlBox.Text = result; mainWindow.Activate(); }
//private void MouseHook_DoubleClick(MouseHook.MSLLHOOKSTRUCT mouseStruct) //{ // Point point = new Point(mouseStruct.pt.x, mouseStruct.pt.y); // Add add = new Add(AddList); // IAsyncResult result = add.BeginInvoke(point, 2, null, null); //} private void AddList(Point point, int type) { AutomationElement ae = AutomationElement.FromPoint(point); //PrintAllTree(ae);/// String inputText = null; if (ae != null) { AutomationPattern[] aps = ae.GetSupportedPatterns(); foreach (AutomationPattern ap in aps) { //Console.WriteLine(ap.ProgrammaticName); if (ap == ValuePattern.Pattern) { ValuePattern valuePattern = ae.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; if (valuePattern.Current.IsReadOnly == false) { RecordList.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { Stop(); InputBox inputBox = new InputBox(); inputBox.ShowDialog(); inputText = inputBox.InputText.Text; if (inputText == "") { type = 2; //dbclcik } else { type = 3; } Start(); })); } } } } String xmlData = XmlController.MakeXmlFile(XmlController.MakeStack(ae), type, inputText); RecordList.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { ElementQueue.Enqueue(xmlData); RecordList.Items.Add(xmlData); })); }