For Internet Explorer, you can use COM automation to enumerate all active Internet Explorer windows/tabs and then access the DOM tree of the document displayed in the window/tab to access and read the scroll position.
The following sample code uses Delphi as a programming language. The mechanism would be similar in C++, VB or C#
var
ShWindows: ShellWindows;
InetExplorer: InternetExplorer;
Count: Integer;
I: Integer;
HTMLDocument: IHTMLDocument2;
Elem: IHTMLElement2;
ScrollPosY: Integer;
begin
// Create ShellWindows Object
SHWindows:= CoShellWindows.Create;
// Number of explorer windows/tabs (win explorer and ie)
Count:= ShWindows.Count;
ShowMessage(Format('There are %d explorer windows open.', [Count]));
// For all windows/tabs
for I:= 0 to (Count - 1) do
begin
// Get as InetExplorer interface
InetExplorer:= SHWindows.item(I) as InternetExplorer;
// Check to see if this explorer window contains a web document
if Supports(InetExplorer.Document, IHTMLDocument2, HTMLDocument) then
begin
// Get body Element
Elem:= HTMLDocument.body as IHTMLElement2;
// Read vertical scroll position
ScrollPosY:= Elem.scrollTop;
// If this is 0 so far, maybe there is a scroll position in root element
if ScrollPosY = 0 then
begin
Elem:= HTMLDocument.body.parentElement as IHTMLElement2;
ScrollPosY:= Elem.scrollTop;
end;
// Display
ShowMessage(IntToStr(Elem.scrollTop));
end;
end;
end;
For documentation, start here: http://msdn.microsoft.com/en-us/library/bb773974(VS.85).aspx