Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IE - Automatic Scroll?

14 views
Skip to first unread message

Lando

unread,
Feb 12, 2003, 9:04:21 AM2/12/03
to
I have a login script that writes status messages to an IE window. The web
page is built on the fly as the login commands are processed. I am using
MSIE = CreateObject("InternetExplorer.Application") and MSIE.Document.Write
commands to write to the page. Is there a way to have the IE window
automatically scroll down when the next line is written to the page? As it
is now, the page just writes past the browser bottom so you can't see what's
happening. I can have the page scroll up automatically after the full page
is complete but I prefer scrolling it as it's processing. Any sample code
would be appreciated.

Thanks,
Lando


Joe Earnest

unread,
Feb 12, 2003, 12:21:30 PM2/12/03
to
Hi,

A good site for DHTML is
http://www.w3schools.com/dhtml/default.asp

Check out the overflow:scroll style and the window.scrollto
option.

*If* this is WSH-hosted, then using IEApp from the WSH
host, the easiest way to accomplish this is to use a textarea
box that you can write to with sendkeys (it automatically scrolls
continuously). (AutoItX is more reliable than sendkeys, if you
have it installed.) I've previously posted a NoticeDemo2.vbs
script that does that. It's a fairly good size attachment. If you
want a copy, post back and I'll email it to you. I don't know if
sendkeys is available on an ASP or HTML (or if you'd want to
chance using it on those hosts). You can just change the value
in the textarea box. That does not get you the automatic scroll,
but you can add the new data to the top, instead of the bottom.

Joe Earnest

"Lando" <la...@noemails.com> wrote in message
news:OlrDZ#p0CHA.1656@TK2MSFTNGP09...

Torgeir Bakken (MVP)

unread,
Feb 12, 2003, 1:53:30 PM2/12/03
to
Lando wrote:

Hi

I use this Sub in my logon script to always scroll at bottom:


Sub MsgMSIE(sMsg)
On Error Resume Next
oTheEnd.insertAdjacentHtml "beforeBegin", sMsg & "<BR>"
oTheEnd.scrollIntoView
End Sub


And when setting up the IE object:

With oIE
(snip)
With .document
(snip)

.Open
.Write "<span id='theEnd'></span>"
.Close
Set oTheEnd = .all.theEnd
.Title = sTitle

Full example:


Dim oTheEnd ' important that this is dimmed as a global variable!!!

Set oIE = CreateObject("InternetExplorer.Application")
SetupMSIE

MsgMSIE "<BR>Processing Logon Script..."
MsgMSIE "<HR><BR>"

' rest of logon script


Sub SetupMSIE
Dim sTitle, SWidth,SHeight, SWidthW, SHeightW

sTitle = "AD Logon"

With oIE

' Not an option with IE 6 SP1
'.FullScreen = True

.AddressBar = False
.ToolBar = False
.StatusBar = False
.Resizable = False
.Navigate("about:blank")
Do Until .readyState = 4: wscript.sleep 100: Loop

With .document
With .ParentWindow
SWidth = .Screen.AvailWidth
SHeight = .Screen.AvailHeight

SWidthW = .Screen.AvailWidth / 2
SHeightW = .Screen.AvailHeight / 1.5

.resizeto SWidthW, SHeightW
.moveto (SWidth - SWidthW)/2, (SHeight - SHeightW)/2

End With

.Open
.Write "<span id='theEnd'></span>"
.Close
Set oTheEnd = .all.theEnd
.Title = sTitle

With .ParentWindow.document.body
.style.backgroundcolor = "LightBlue"
.style.Font = "10pt 'Arial'"
'.style.borderStyle = "outset"
'.style.borderWidth = "4px"
' .scroll="no"
End With
oIE.Visible = True

End With ' document
End With ' oIE
End Sub


Sub MsgMSIE(sMsg)
On Error Resume Next
oTheEnd.insertAdjacentHtml "beforeBegin", sMsg & "<BR>"
oTheEnd.scrollIntoView
End Sub


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Joe Earnest

unread,
Feb 12, 2003, 6:56:32 PM2/12/03
to
Hi Torgeir,

Very nice.

Regards,
Joe Earnest

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3E4A982A...@hydro.com...


> Hi
>
> I use this Sub in my logon script to always scroll at bottom:

> (snip)


> And when setting up the IE object:

> (snip)
> Full example:
> (snip)

Torgeir Bakken (MVP)

unread,
Feb 12, 2003, 7:06:36 PM2/12/03
to
Joe Earnest wrote:

> "Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
> news:3E4A982A...@hydro.com...
> > Hi
> >
> > I use this Sub in my logon script to always scroll at bottom:
> > (snip)
>

> Hi Torgeir,
>
> Very nice.

Thanks :-)

If my memory doesn't fail me, I picked up the oTheEnd.insertAdjacentHtml
"beforeBegin" trick from some Michael Harris code...

0 new messages