public bool ParseUserAction(ref IRecordEvent e) { if (e.UIElement == null) { return(false); } if (e.UIElement.ProcessId < 1) { return(false); } var p = System.Diagnostics.Process.GetProcessById(e.UIElement.ProcessId); if (p.ProcessName.ToLower() != "chrome" && p.ProcessName.ToLower() != "firefox") { return(false); } if (p.ProcessName.ToLower() == "chrome" && !NMHook.chromeconnected) { System.Windows.MessageBox.Show("You clicked inside Chrome, but it looks like you dont have the OpenRPA plugin installed"); return(false); } if (p.ProcessName.ToLower() == "firefox" && !NMHook.ffconnected) { System.Windows.MessageBox.Show("You clicked inside Firefix, but it looks like you dont have the OpenRPA plugin installed"); return(false); } if (LastElement == null) { return(false); } var selector = new NMSelector(LastElement, null, true, null); var a = new GetElement { DisplayName = LastElement.id + " " + LastElement.type + " " + LastElement.Name }; a.Selector = selector.ToString(); a.Image = LastElement.ImageString(); a.MaxResults = 1; e.Element = LastElement; e.Selector = selector; e.a = new GetElementResult(a); e.SupportInput = LastElement.SupportInput; e.SupportSelect = false; e.OffsetX = e.X - LastElement.Rectangle.X; e.OffsetY = e.Y - LastElement.Rectangle.Y; e.ClickHandled = false; //e.ClickHandled = true; //LastElement.Click(true, e.Button, e.X, e.Y, false, false); return(true); }
private void OnMessage(NativeMessagingMessage message) { try { if (message.uiy > 0 && message.uix > 0 && message.uiwidth > 0 && message.uiheight > 0) { if (!string.IsNullOrEmpty(message.data)) { LastElement = new NMElement(message); } else { LastElement = new NMElement(message); } } if (message.functionName == "click") { if (IsRecording) { if (LastElement == null) { return; } var re = new RecordEvent { Button = Input.MouseButton.Left }; var a = new GetElement { DisplayName = LastElement.ToString() }; var selector = new NMSelector(LastElement, null, true, null); a.Selector = selector.ToString(); a.Image = LastElement.ImageString(); a.MaxResults = 1; re.Selector = selector; re.a = new GetElementResult(a); re.SupportInput = LastElement.SupportInput; re.SupportSelect = false; re.ClickHandled = true; OnUserAction?.Invoke(this, re); return; } } } catch (Exception ex) { Log.Error(ex.ToString()); } }
private void OnMessage(NativeMessagingMessage message) { try { //lock(_lock) //{ // //if (dpiscale == 0) // //{ // // dpiscale = NativeMethods.getScalingFactor(); // //} else // //{ // // dpiscale = NativeMethods.getScalingFactor(); // //} // var dpi = NativeMethods.GetDpiForSystem(); // dpiscale = 1; // if (dpi == 96) dpiscale = 1; // if (dpi == 120) dpiscale = 1.25f; // if (dpi == 144) dpiscale = 1.5f; // if (dpi == 192) dpiscale = 2; //} if (message.uiy > 0 && message.uix > 0 && message.uiwidth > 0 && message.uiheight > 0) { //message.uiy = (int)(message.uiy * dpiscale); //message.uix = (int)(message.uix * dpiscale); //message.uiwidth = (int)(message.uiwidth * dpiscale); //message.uiheight = (int)(message.uiheight * dpiscale); if (dpiscale == 1.25) { message.uiy += 158; } LastElement = new NMElement(message); } if (message.functionName == "click") { if (IsRecording) { if (LastElement == null) { return; } var re = new RecordEvent { Button = Input.MouseButton.Left }; var a = new GetElement { DisplayName = LastElement.ToString() }; message.tab = NMHook.tabs.Where(x => x.id == message.tabid && x.windowId == message.windowId).FirstOrDefault(); var selector = new NMSelector(LastElement, null, true, null); a.Selector = selector.ToString(); a.Image = LastElement.ImageString(); a.MaxResults = 1; re.Selector = selector; re.a = new GetElementResult(a); re.SupportInput = LastElement.SupportInput; re.SupportSelect = false; re.ClickHandled = true; OnUserAction?.Invoke(this, re); return; } } } catch (Exception ex) { Log.Error(ex.ToString()); } }
public bool ParseUserAction(ref IRecordEvent e) { if (e.UIElement == null) { return(false); } if (e.UIElement.ProcessId < 1) { return(false); } using (var p = System.Diagnostics.Process.GetProcessById(e.UIElement.ProcessId)) { if (p.ProcessName.ToLower() != "chrome" && p.ProcessName.ToLower() != "firefox" && p.ProcessName.ToLower() != "msedge") { return(false); } if (p.ProcessName.ToLower() == "chrome") { if (!NMHook.chromeconnected) { System.Windows.MessageBox.Show("You clicked inside Chrome, but it looks like you dont have the OpenRPA plugin installed"); return(false); } if (string.IsNullOrEmpty(e.UIElement.FrameworkId) || e.UIElement.FrameworkId.ToLower() != "chrome") { return(false); } } if (p.ProcessName.ToLower() == "msedge" && !NMHook.edgeconnected) { System.Windows.MessageBox.Show("You clicked inside Edge, but it looks like you dont have the OpenRPA plugin installed"); return(false); } if (p.ProcessName.ToLower() == "firefox" && !NMHook.ffconnected) { System.Windows.MessageBox.Show("You clicked inside Firefix, but it looks like you dont have the OpenRPA plugin installed"); return(false); } if (LastElement == null) { return(false); } if (LastElement.message == null) { return(false); } if (LastElement.message.tab == null) { LastElement.message.tab = NMHook.FindTabById(LastElement.message.browser, LastElement.message.tabid); } if (p.ProcessName.ToLower() == "chrome" || p.ProcessName.ToLower() == "msedge") { // if (e.UIElement.FrameworkId != "chrome" && e.UIElement.FrameworkId != "Chrome") return false; } } var selector = new NMSelector(LastElement, null, true, null); var a = new GetElement { DisplayName = LastElement.id + " " + LastElement.type + " " + LastElement.Name }; a.Variables.Add(new Variable <int>("Index", 0)); a.Variables.Add(new Variable <int>("Total", 0)); a.Selector = selector.ToString(); a.Image = LastElement.ImageString(); a.MaxResults = 1; e.Element = LastElement; e.Selector = selector; e.a = new GetElementResult(a); e.SupportInput = LastElement.SupportInput; e.SupportSelect = LastElement.tagname.ToLower() == "select"; e.OffsetX = e.X - LastElement.Rectangle.X; e.OffsetY = e.Y - LastElement.Rectangle.Y; e.ClickHandled = false; //e.ClickHandled = true; //LastElement.Click(true, e.Button, e.X, e.Y, false, false); return(true); }