private void Open_Selector(object sender, RoutedEventArgs e) { ModelItem loadFrom = ModelItem.Parent; string loadFromSelectorString = ""; IESelector anchor = null; while (loadFrom.Parent != null) { var p = loadFrom.Properties.Where(x => x.Name == "Selector").FirstOrDefault(); if (p != null) { loadFromSelectorString = loadFrom.GetValue <string>("Selector"); anchor = new IESelector(loadFromSelectorString); break; } loadFrom = loadFrom.Parent; } string SelectorString = ModelItem.GetValue <string>("Selector"); int maxresults = ModelItem.GetValue <int>("MaxResults"); Interfaces.Selector.SelectorWindow selectors; if (!string.IsNullOrEmpty(SelectorString)) { var selector = new IESelector(SelectorString); selectors = new Interfaces.Selector.SelectorWindow("IE", selector, anchor, maxresults); } else { var selector = new IESelector("[{Selector: 'IE'}]"); selectors = new Interfaces.Selector.SelectorWindow("IE", selector, anchor, maxresults); } if (selectors.ShowDialog() == true) { ModelItem.Properties["Selector"].SetValue(new InArgument <string>() { Expression = new Literal <string>(selectors.vm.json) }); var l = selectors.vm.Selector.Last(); if (l.Element != null) { ModelItem.Properties["Image"].SetValue(l.Element.ImageString()); NotifyPropertyChanged("Image"); } if (anchor != null) { ModelItem.Properties["From"].SetValue(new InArgument <IEElement>() { Expression = new Microsoft.VisualBasic.Activities.VisualBasicValue <IEElement>("item") }); ModelItem.Properties["MinResults"].SetValue(new InArgument <int>() { Expression = new Microsoft.VisualBasic.Activities.VisualBasicValue <int>("0") }); ModelItem.Properties["Timeout"].SetValue(new InArgument <TimeSpan>() { Expression = new Microsoft.VisualBasic.Activities.VisualBasicValue <TimeSpan>("TimeSpan.FromSeconds(0)") }); } } }
private void Open_Selector_Click(object sender, RoutedEventArgs e) { string SelectorString = plugin.Selector; Interfaces.Selector.SelectorWindow selectors; if (!string.IsNullOrEmpty(SelectorString)) { var selector = new JavaSelector(SelectorString); selectors = new Interfaces.Selector.SelectorWindow("Java", selector, null, 10); } else { var selector = new JavaSelector("[{Selector: 'Java'}]"); selectors = new Interfaces.Selector.SelectorWindow("Java", selector, null, 10); } if (selectors.ShowDialog() == true) { plugin.Selector = selectors.vm.json; NotifyPropertyChanged("Selector"); } }
private void Open_Selector(object sender, RoutedEventArgs e) { string SelectorString = ModelItem.GetValue <string>("Selector"); int maxresult = 1; if (string.IsNullOrEmpty(SelectorString)) { SelectorString = "[{Selector: 'Windows'}]"; } var selector = new Interfaces.Selector.Selector(SelectorString); var pluginname = selector.First().Selector; var selectors = new Interfaces.Selector.SelectorWindow(pluginname, selector, maxresult); if (selectors.ShowDialog() == true) { ModelItem.Properties["Selector"].SetValue(new InArgument <string>() { Expression = new Literal <string>(selectors.vm.json) }); } }
private void Open_Selector_Click(object sender, RoutedEventArgs e) { string SelectorString = Selector; Interfaces.Selector.SelectorWindow selectors; if (!string.IsNullOrEmpty(SelectorString)) { var selector = new WindowsSelector(SelectorString); selectors = new Interfaces.Selector.SelectorWindow("Windows", selector, null, 10); } else { var selector = new WindowsSelector("[{Selector: 'Windows'}]"); selectors = new Interfaces.Selector.SelectorWindow("Windows", selector, null, 10); } // selectors.Owner = GenericTools.MainWindow; -- Locks up and never returns ? if (selectors.ShowDialog() == true) { Selector = selectors.vm.json; NotifyPropertyChanged("EntityName"); NotifyPropertyChanged("Selector"); } }
private void Open_Selector(object sender, RoutedEventArgs e) { string SelectorString = ModelItem.GetValue <string>("Selector"); int maxresult = 1; if (string.IsNullOrEmpty(SelectorString)) { SelectorString = "[{Selector: 'Windows'}]"; } var selector = new Interfaces.Selector.Selector(SelectorString); var pluginname = selector.First().Selector; var selectors = new Interfaces.Selector.SelectorWindow(pluginname, selector, maxresult); if (selectors.ShowDialog() == true) { ModelItem.Properties["Selector"].SetValue(new InArgument <string>() { Expression = new Literal <string>(selectors.vm.json) }); var Plugin = Interfaces.Plugins.recordPlugins.Where(x => x.Name == pluginname).First(); var _base = Plugin.GetElementsWithSelector(selector, null, 10); if (_base == null || _base.Length == 0) { return; } var ele = _base[0]; if (ele != null && !(ele is UIElement)) { var automation = AutomationUtil.getAutomation(); var p = new System.Drawing.Point(ele.Rectangle.X + 10, ele.Rectangle.Y + 10); if (p.X > 0 && p.Y > 0) { var _temp = automation.FromPoint(p); if (_temp != null) { ele = new UIElement(_temp); } } } if (ele is UIElement ui) { var window = ui.GetWindow(); if (window == null) { return; } if (!string.IsNullOrEmpty(window.Name)) { ModelItem.Properties["DisplayName"].SetValue(window.Name); } if (window.Properties.BoundingRectangle.IsSupported) { var bound = window.BoundingRectangle; ModelItem.Properties["X"].SetValue(new InArgument <int>() { Expression = new Literal <int>(bound.X) }); ModelItem.Properties["Y"].SetValue(new InArgument <int>() { Expression = new Literal <int>(bound.Y) }); ModelItem.Properties["Width"].SetValue(new InArgument <int>() { Expression = new Literal <int>(bound.Width) }); ModelItem.Properties["Height"].SetValue(new InArgument <int>() { Expression = new Literal <int>(bound.Height) }); } } } }
private void Open_Selector(object sender, RoutedEventArgs e) { string SelectorString = ModelItem.GetValue <string>("Selector"); int maxresult = 1; if (string.IsNullOrEmpty(SelectorString)) { SelectorString = "[{Selector: 'Windows'}]"; } var selector = new Interfaces.Selector.Selector(SelectorString); var pluginname = selector.First().Selector; var selectors = new Interfaces.Selector.SelectorWindow(pluginname, selector, maxresult); // selectors.Owner = GenericTools.MainWindow; -- Locks up and never returns ? if (selectors.ShowDialog() == true) { ModelItem.Properties["Selector"].SetValue(new InArgument <string>() { Expression = new Literal <string>(selectors.vm.json) }); var Plugin = Interfaces.Plugins.recordPlugins.Where(x => x.Name == pluginname).First(); var _base = Plugin.GetElementsWithSelector(selector, null, 10); if (_base == null || _base.Length == 0) { return; } var ele = _base[0]; if (ele != null && !(ele is UIElement)) { var automation = AutomationUtil.getAutomation(); var p = new System.Drawing.Point(ele.Rectangle.X + 10, ele.Rectangle.Y + 10); if (p.X > 0 && p.Y > 0) { var _temp = automation.FromPoint(p); if (_temp != null) { ele = new UIElement(_temp); } } } if (ele is UIElement ui) { var window = ui.GetWindow(); if (window == null) { return; } if (!string.IsNullOrEmpty(window.Name)) { ModelItem.Properties["DisplayName"].SetValue(window.Name); } if (window.Properties.BoundingRectangle.IsSupported) { var bound = window.BoundingRectangle; var newbound = new System.Drawing.Rectangle(bound.X, bound.Y, bound.Width, bound.Height); var p = new System.Drawing.Point(bound.X, bound.Y); var allScreens = System.Windows.Forms.Screen.AllScreens.ToList(); int screen = 0; for (var i = 0; i < allScreens.Count; i++) { var work = allScreens[i].WorkingArea; if (work.Contains(bound) || allScreens[i].WorkingArea.Contains(p)) { screen = i; newbound.X = newbound.X - work.X; newbound.Y = newbound.Y - work.Y; break; } } ModelItem.Properties["Screen"].SetValue(new InArgument <int>() { Expression = new Literal <int>(screen) }); ModelItem.Properties["X"].SetValue(new InArgument <int>() { Expression = new Literal <int>(newbound.X) }); ModelItem.Properties["Y"].SetValue(new InArgument <int>() { Expression = new Literal <int>(newbound.Y) }); ModelItem.Properties["Width"].SetValue(new InArgument <int>() { Expression = new Literal <int>(newbound.Width) }); ModelItem.Properties["Height"].SetValue(new InArgument <int>() { Expression = new Literal <int>(newbound.Height) }); } } } }