public void AutoScroll(IRunWebPage runPage, IWebBrowser webBrowser, int toPos, int maxStepLength, int minStepSleep, int maxStepSleep) { int pos = 0; Random random = new Random(DateTime.Now.Millisecond); while (pos < toPos) { int randomValue = random.Next(maxStepLength); pos += randomValue; runPage.InvokeScrollDocumentMethod(webBrowser, new Point(pos, pos)); ProcessThread.SleepRandom(minStepSleep, maxStepSleep); } }
public static void AutoScroll(IRunWebPage runPage, IWebBrowser webBrowser, int toPosX, int toPosY, int maxStepLength, int minStepSleep, int maxStepSleep) { int posX = 0; int posY = 0; Random random = new Random(DateTime.Now.Millisecond); while (posX < toPosX || posY < toPosY) { int randomValue = random.Next(maxStepLength); posX = toPosX <= posX ? toPosX : posX + randomValue; posY = toPosY <= posY ? toPosY : posY + randomValue; runPage.InvokeScrollDocumentMethod(webBrowser, new Point(posX, posY)); ProcessThread.SleepRandom(minStepSleep, maxStepSleep); } }