public static bool ScrollToAbsolutePoint(IntPtr hwnd, mshtml.IHTMLDocument2 doc, int scrollTop, int y, int scrollHeight, int winHeight, ref Point fakeMousePoint, bool scrollFast, bool isTimeout, HtmlElement htmlElement) { int num2; bool flag = false; int num = 0; Random random = new Random(); if (isTimeout) { if (htmlElement == null) { return(flag); } int num3 = y - (winHeight / 2); if (num3 < 0) { num3 = 0; } else if (num3 > (scrollHeight - winHeight)) { num3 = scrollHeight - winHeight; } htmlElement.ScrollTop = num3; return(true); } if (scrollFast) { num2 = 100; } else { num2 = random.Next(5, 10); } CheckMousePoint(hwnd, ref fakeMousePoint, doc); while (!flag && (num < num2)) { int windowMessageLParam = GetWindowMessageLParam(hwnd, fakeMousePoint); if ((y <= ((scrollTop + (winHeight / 2)) - 120)) && (scrollTop > 0)) { scrollTop = ((scrollTop - 120) >= 0) ? (scrollTop - 120) : 0; WindowUtil.PostMessage(hwnd, 0x20a, 0x780000, windowMessageLParam); } else if ((y >= ((scrollTop + (winHeight / 2)) + 120)) && ((scrollTop + winHeight) < scrollHeight)) { scrollTop = (((scrollTop + winHeight) + 120) <= scrollHeight) ? (scrollTop + 120) : (scrollHeight - winHeight); WindowUtil.PostMessage(hwnd, 0x20a, -7864320, windowMessageLParam); } else { flag = true; } num++; } return(flag); }
public static bool MoveToDest(IntPtr hwnd, HtmlElement htmlElement, mshtml.IHTMLDocument2 doc, int x, int y, ref Point fakeMousePoint, bool scrollfast, bool isTimeout) { bool flag = true; int clientWidth = 0; int clientHeight = 0; int scrollWidth = 0; int scrollHeight = 0; if ((GetWindowWidthAndHeight(hwnd, doc, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight) != null) && (htmlElement != null)) { int scrollLeft = htmlElement.ScrollLeft; int scrollTop = htmlElement.ScrollTop; if ((clientWidth == 0) && (clientHeight == 0)) { return(flag); } flag = ScrollToAbsolutePoint(hwnd, doc, scrollTop, y + scrollTop, scrollHeight, clientHeight, ref fakeMousePoint, scrollfast, isTimeout, htmlElement); if (!flag) { return(flag); } flag = false; int num7 = 0; if (((scrollLeft + x) + (clientWidth / 2)) > scrollWidth) { num7 = scrollWidth - clientWidth; } else if ((scrollLeft + x) < (clientWidth / 2)) { num7 = 0; } else { num7 = (scrollLeft + x) - (clientWidth / 2); } htmlElement.ScrollLeft = num7; if ((x + scrollLeft) < 0) { x = 4; } else if ((x + scrollLeft) > scrollWidth) { x = clientWidth - 8; } if (((scrollLeft + x) >= num7) && ((scrollLeft + x) <= (num7 + clientWidth))) { SetMousePoint(hwnd, ref fakeMousePoint, x, y, doc); int lParam = (fakeMousePoint.Y << 0x10) + fakeMousePoint.X; WindowUtil.PostMessage(hwnd, 0x200, 0, lParam); flag = true; } } return(flag); }
public static bool MoveToDest(IntPtr hwnd, mshtml.IHTMLDocument2 doc, Point to, ref Point fakeMousePoint) { bool flag = false; int clientWidth = 0; int clientHeight = 0; int scrollWidth = 0; int scrollHeight = 0; if ((GetWindowWidthAndHeight(hwnd, doc, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight) != null) && ((clientWidth != 0) || (clientHeight != 0))) { int num5 = 50; if ((Math.Abs((int)(fakeMousePoint.Y - to.Y)) >= num5) || (Math.Abs((int)(fakeMousePoint.X - to.X)) >= num5)) { if (((to.X >= 0) && (to.X < clientWidth)) && ((to.Y >= 0) && (to.Y <= clientHeight))) { Random random = new Random(); int num6 = 0; int num7 = 0; if ((fakeMousePoint.X - to.X) > 0) { num6 = -random.Next(Math.Max(fakeMousePoint.X - to.X, 50)); } else if ((fakeMousePoint.X - to.X) < 0) { num6 = random.Next(Math.Max(to.X - fakeMousePoint.X, 50)); } if ((fakeMousePoint.Y - to.Y) > 0) { num7 = -random.Next(Math.Max(fakeMousePoint.Y - to.Y, 50)); } else if ((fakeMousePoint.Y - to.Y) < 0) { num7 = random.Next(Math.Max(to.Y - fakeMousePoint.Y, 50)); } SetMousePoint(ref fakeMousePoint, fakeMousePoint.X + num6, fakeMousePoint.Y + num7, clientWidth, clientHeight); int lParam = (fakeMousePoint.Y << 0x10) + fakeMousePoint.X; WindowUtil.PostMessage(hwnd, 0x200, 0, lParam); } return(flag); } flag = true; if ((fakeMousePoint.Y != to.Y) || (fakeMousePoint.X != to.X)) { SetMousePoint(ref fakeMousePoint, to.X, to.Y, clientWidth, clientHeight); int num9 = (fakeMousePoint.Y << 0x10) + fakeMousePoint.X; WindowUtil.PostMessage(hwnd, 0x200, 0, num9); } } return(flag); }