private void CancelOverlay() { var p = Plugins.recordPlugins.Where(x => x.Name == "Windows").First(); if (Config.local.record_overlay) { p.OnMouseMove -= OnMouseMove; } p.Stop(); if (_overlayWindow != null) { GenericTools.RunUI(_overlayWindow, () => { try { _overlayWindow.Visible = true; _overlayWindow.Dispose(); } catch (Exception ex) { Log.Error(ex.ToString()); } }); } _overlayWindow = null; }
private async void btn_Select(object sender, RoutedEventArgs e) { Rectangle match = await GetBaseRectangle(); Rectangle rect = Rectangle.Empty; using (Interfaces.Overlay.OverlayWindow _overlayWindow = new Interfaces.Overlay.OverlayWindow(true)) { _overlayWindow.BackColor = System.Drawing.Color.Blue; _overlayWindow.Visible = true; _overlayWindow.Bounds = match; _overlayWindow.TopMost = true; var msg = "Select relative area to capture"; if (match.IsEmpty) { msg = "Select desktop area to capture"; } var tip = new Interfaces.Overlay.TooltipWindow(msg); rect = await getrectangle.GetitAsync(); tip.Close(); tip = null; } ModelItem.Properties["X"].SetValue(new System.Activities.InArgument <int>(rect.X - match.X)); ModelItem.Properties["Y"].SetValue(new System.Activities.InArgument <int>(rect.Y - match.Y)); ModelItem.Properties["Width"].SetValue(new System.Activities.InArgument <int>(rect.Width)); ModelItem.Properties["Height"].SetValue(new System.Activities.InArgument <int>(rect.Height)); Interfaces.GenericTools.Restore(); }
private async void btn_Select(object sender, RoutedEventArgs e) { ModelItem loadFrom = ModelItem.Parent; string loadFromSelectorString = ""; while (loadFrom.Parent != null) { var p = loadFrom.Properties.Where(x => x.Name == "Image").FirstOrDefault(); if (p != null) { loadFromSelectorString = loadFrom.GetValue <string>("Selector"); break; } loadFrom = loadFrom.Parent; } var Image = loadFrom.GetValue <string>("Image"); var stream = new System.IO.MemoryStream(Convert.FromBase64String(Image)); var b = new System.Drawing.Bitmap(stream); var Threshold = loadFrom.GetValue <double>("Threshold"); var CompareGray = loadFrom.GetValue <bool>("CompareGray"); var Processname = loadFrom.GetValue <string>("Processname"); var limit = loadFrom.GetValue <Rectangle>("Limit"); if (Threshold < 0.5) { Threshold = 0.8; } Interfaces.GenericTools.Minimize(); System.Threading.Thread.Sleep(100); var matches = ImageEvent.waitFor(b, Threshold, Processname, TimeSpan.FromMilliseconds(100), CompareGray, limit); if (matches.Count() == 0) { Interfaces.GenericTools.Restore(); return; } var match = matches[0]; Rectangle rect = Rectangle.Empty; using (Interfaces.Overlay.OverlayWindow _overlayWindow = new Interfaces.Overlay.OverlayWindow(true)) { _overlayWindow.BackColor = System.Drawing.Color.Blue; _overlayWindow.Visible = true; _overlayWindow.Bounds = match; _overlayWindow.TopMost = true; rect = await getrectangle.GetitAsync(); } ModelItem.Properties["OffsetX"].SetValue(new System.Activities.InArgument <int>(rect.X - match.X)); ModelItem.Properties["OffsetY"].SetValue(new System.Activities.InArgument <int>(rect.Y - match.Y)); ModelItem.Properties["Width"].SetValue(new System.Activities.InArgument <int>(rect.Width)); ModelItem.Properties["Height"].SetValue(new System.Activities.InArgument <int>(rect.Height)); Interfaces.GenericTools.Restore(); }
private async void btn_Select(object sender, RoutedEventArgs e) { Interfaces.GenericTools.Minimize(); var limit = ModelItem.GetValue <Rectangle>("Limit"); Rectangle rect = Rectangle.Empty; Log.Information(limit.ToString()); using (Interfaces.Overlay.OverlayWindow _overlayWindow = new Interfaces.Overlay.OverlayWindow(true)) { _overlayWindow.BackColor = System.Drawing.Color.Blue; var tip = new Interfaces.Overlay.TooltipWindow("Select area to look for"); if (limit != Rectangle.Empty) { _overlayWindow.Visible = true; _overlayWindow.Bounds = limit; _overlayWindow.TopMost = true; _overlayWindow.Opacity = 0.3; tip.setText("Select area to look for within the blue area"); } rect = await getrectangle.GetitAsync(); tip.Close(); tip = null; } if (limit != Rectangle.Empty) { if (!limit.Contains(rect)) { Log.Error(rect.ToString() + " is not within process limit of " + limit.ToString()); Interfaces.GenericTools.Restore(); return; } } var _image = new System.Drawing.Bitmap(rect.Width, rect.Height); var graphics = System.Drawing.Graphics.FromImage(_image as System.Drawing.Image); graphics.CopyFromScreen(rect.X, rect.Y, 0, 0, _image.Size); ModelItem.Properties["Image"].SetValue(Interfaces.Image.Util.Bitmap2Base64(_image)); NotifyPropertyChanged("Image"); var element = AutomationHelper.GetFromPoint(rect.X, rect.Y); if (element != null) { using (var p = System.Diagnostics.Process.GetProcessById(element.ProcessId)) { var Processname = p.ProcessName; ModelItem.Properties["Processname"].SetValue(new System.Activities.InArgument <string>(Processname)); } } Interfaces.GenericTools.Restore(); }
private void StartOverlay() { var p = Plugins.recordPlugins.Where(x => x.Name == "Windows").First(); if (Config.local.record_overlay) { p.OnMouseMove += OnMouseMove; } p.Start(); if (_overlayWindow == null && Config.local.record_overlay) { _overlayWindow = new Interfaces.Overlay.OverlayWindow(true) { BackColor = System.Drawing.Color.PaleGreen, Visible = true, TopMost = true }; } }
private async void btn_Select(object sender, RoutedEventArgs e) { ModelItem loadFrom = ModelItem.Parent; string loadFromSelectorString = ""; ModelItem gettext = null; while (loadFrom.Parent != null) { var p = loadFrom.Properties.Where(x => x.Name == "Image").FirstOrDefault(); if (p != null) { loadFromSelectorString = loadFrom.GetValue <string>("Selector"); break; } if (loadFrom.ItemType == typeof(GetText)) { gettext = loadFrom; } loadFrom = loadFrom.Parent; } Interfaces.IElement element = null; Rectangle match = Rectangle.Empty; if (!string.IsNullOrEmpty(loadFromSelectorString)) { var selector = new Interfaces.Selector.Selector(loadFromSelectorString); var pluginname = selector.First().Selector; var Plugin = Interfaces.Plugins.recordPlugins.Where(x => x.Name == pluginname).First(); var elements = Plugin.GetElementsWithSelector(selector, null, 1); if (elements.Length > 0) { element = elements[0]; } } if (gettext != null && element != null) { var matches = GetText.Execute(element, gettext); if (matches.Length > 0) { match = matches[0].Rectangle; } else { var tip = new Interfaces.Overlay.TooltipWindow("Mark a found item"); match = await getrectangle.GetitAsync(); tip.Close(); tip = null; } } else { var Image = loadFrom.GetValue <string>("Image"); var stream = new System.IO.MemoryStream(Convert.FromBase64String(Image)); var b = new System.Drawing.Bitmap(stream); var Threshold = loadFrom.GetValue <double>("Threshold"); var CompareGray = loadFrom.GetValue <bool>("CompareGray"); var Processname = loadFrom.GetValue <string>("Processname"); var limit = loadFrom.GetValue <Rectangle>("Limit"); if (Threshold < 0.5) { Threshold = 0.8; } Interfaces.GenericTools.minimize(Interfaces.GenericTools.mainWindow); System.Threading.Thread.Sleep(100); var matches = ImageEvent.waitFor(b, Threshold, Processname, TimeSpan.FromMilliseconds(100), CompareGray, limit); if (matches.Count() == 0) { Interfaces.GenericTools.restore(); return; } match = matches[0]; } Rectangle rect = Rectangle.Empty; using (Interfaces.Overlay.OverlayWindow _overlayWindow = new Interfaces.Overlay.OverlayWindow(true)) { _overlayWindow.BackColor = System.Drawing.Color.Blue; _overlayWindow.Visible = true; _overlayWindow.Bounds = match; _overlayWindow.TopMost = true; var tip = new Interfaces.Overlay.TooltipWindow("Select relative area to capture"); rect = await getrectangle.GetitAsync(); tip.Close(); tip = null; } ModelItem.Properties["OffsetX"].SetValue(new System.Activities.InArgument <int>(rect.X - match.X)); ModelItem.Properties["OffsetY"].SetValue(new System.Activities.InArgument <int>(rect.Y - match.Y)); ModelItem.Properties["Width"].SetValue(new System.Activities.InArgument <int>(rect.Width)); ModelItem.Properties["Height"].SetValue(new System.Activities.InArgument <int>(rect.Height)); Interfaces.GenericTools.restore(); }