void myBrowser_WBMouseMove(object sender, csExWB.HTMLMouseEventArgs e) { if (dragging) { //e.Handled = true; System.Diagnostics.Debug.WriteLine("myBrowser_WBMouseMove"); Graphics g = myBrowser.CreateGraphics(); // erase frame DrawSelectionFrame(g); // get selection end point GetImageAndScreenPoints(new Point(e.ClientX, e.ClientY), out end, out endW); // draw frame DrawSelectionFrame(g); g.Dispose(); if (SelectionChanged != null) { Point sp = start; Point ep = end; // normalize start and end points NormalizePoints(ref sp, ref ep); SelectionChanged(this, new SelectionEventArgs( sp, new Size(ep.X - sp.X + 1, ep.Y - sp.Y + 1))); } } else { if (MouseImagePosition != null) { Rectangle rc = myBrowser.ClientRectangle; int width = (int)(this.width * zoom); int height = (int)(this.height * zoom); Point scrollPos = myBrowser.GetScroll(); int x = (rc.Width < width) ? scrollPos.X : (rc.Width - width) / 2; int y = (rc.Height < height) ? scrollPos.Y : (rc.Height - height) / 2; if ((e.ClientX >= x) && (e.ClientY >= y) && (e.ClientX < x + width) && (e.ClientY < y + height)) { // mouse is over the image MouseImagePosition(this, new SelectionEventArgs( new Point((int)((e.ClientX - x) / zoom), (int)((e.ClientY - y) / zoom)))); } else { // mouse is outside image region MouseImagePosition(this, new SelectionEventArgs(new Point(-1, -1))); } } } }
private void SimulateClick(IHTMLElement el) { BrowserWindow bw = browser as BrowserWindow; if (bw != null) { MyBrowser wb = bw.WBBrowser as MyBrowser; Point p = wb.GetScroll(); int scrollTop = p.Y; int scrollLeft = p.X; logger.InfoFormat("scrolltop:{0},scrollleft:{1}", scrollTop, scrollLeft); Rectangle rect = browser.GetAbsolutePosition(el); System.Windows.Forms.Control control = wb as System.Windows.Forms.Control; //获取控件绝对位置 Point location = control.PointToScreen(Point.Empty); Point newPosition = new Point(rect.X + rect.Width / 2 - scrollLeft, rect.Y + location.Y - scrollTop + 2); logger.InfoFormat("new position, x:{0}, y:{0}", newPosition.X, newPosition.Y); AutoRobo.Core.Macro.Macror.LinearSmoothMove(newPosition, 200); MouseSimulator.X = newPosition.X; MouseSimulator.Y = newPosition.Y; MouseSimulator.Click(System.Windows.Forms.MouseButtons.Left); } }