Reputation: 575
to be properly understood - this problem has the following accessory:
The following is an example of what I tried to write:
_WebContent.wbThread1.Focus();
int length = 100;
new Thread(() =>
{
for (int i = 0; i <= length; i++)
{
System.Windows.Forms.SendKeys.Send("{PGDN}");
Thread.Sleep(new TimeSpan(0, 0, 3));
st.Start();
}
}).Start();
Everything is going well, but it is a problem to process event SendKey, wee need to focus region for the event, and in case the focus is lost will not spend anything.
I started to look for information on MSDN, and found something very interesting for processing the scrolling :
_WebContent.wbThread1.Document.Body.ScrollIntoView (true) / / allows scrolling to the top
_WebContent.wbThread1.Document.Body.ScrollIntoView (false) / / allows scrolling to the bottom
_WebContent.wbThread1.Document.Body.ScrollLeft = 100, / / sets the offset to the left
_WebContent.wbThread1.Document.Body.ScrollTop = 100, / / sets the upward shift
var rect = _WebContent.wbThread1.Document.Body.ScrollRectangle; / / returns the current position
and this combination of features did not help. Theoretically code works, but in practice I did not had success with this example.
Event after I process scrolling, I will execute something like that:
HtmlElementCollection _HtmlElementCollect = _WebContent.wbThread1.Document.GetElementsByTagName("A");
foreach (HtmlElement link in _HtmlElementCollect)
{
if (link.InnerText.Equals("Load More..."))
link.InvokeMember("Click");
}
What suggestions do you have? How best can I do this scrolling?
Upvotes: 0
Views: 1372
Reputation: 13033
you can scroll to the bottom by using
webCtrl.Document.Window.ScrollTo(0, Int32.MaxValue);
Upvotes: 1