async public static Task <System.Drawing.Rectangle> GetitAsync() { if (VersionHelper.IsWindows8OrGreater()) { _overlayWindow = new Interfaces.Overlay.OverlayWindow(true); } else { _overlayWindow = new Interfaces.Overlay.OverlayWindow(false); } _overlayWindow.Visible = true; _overlayWindow.Bounds = new System.Drawing.Rectangle(0, 0, 10, 10); createform(); mouseDown = false; var pos = System.Windows.Forms.Cursor.Position; rect = new System.Drawing.Rectangle(pos.X, pos.Y, 1, 1); //hi = new Highlighter(rect, System.Drawing.Color.Red); OpenRPA.Input.InputDriver.Instance.OnMouseDown += onMouseDown; OpenRPA.Input.InputDriver.Instance.OnMouseUp += onMouseUp; OpenRPA.Input.InputDriver.Instance.OnMouseMove += onMouseMove; OpenRPA.Input.InputDriver.Instance.onCancel += onCancel; OpenRPA.Input.InputDriver.Instance.CallNext = false; waitHandle = new System.Threading.AutoResetEvent(false); await waitHandle.WaitOneAsync(); //System.Windows.Forms.Application.Exit(); return(rect); }
private static void onMouseUp(InputEventArgs e) { if (rect.Width < 3 || rect.Height < 3) { return; } if (_overlayWindow != null) { _overlayWindow.Dispose(); } _overlayWindow = null; OpenRPA.Input.InputDriver.Instance.OnMouseDown -= onMouseDown; OpenRPA.Input.InputDriver.Instance.OnMouseUp -= onMouseUp; OpenRPA.Input.InputDriver.Instance.OnKeyUp -= OnKeyUp; OpenRPA.Input.InputDriver.Instance.OnMouseMove -= onMouseMove; removeform(); waitHandle.Set(); }