Auto-scrolling HTA output

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
rasimmer
Posts: 182
Last visit: Fri Apr 25, 2014 7:00 am

Auto-scrolling HTA output

Post by rasimmer »

I have an HTA that I am using to display output and once the output goes beyond the bottom of the window, you have to manually scroll to see the progress. In the past I've used a timer and did a send key for {PGDN}, but if you are running the output in the background the send key will Page Down in whatever you are in. Any ideas? rasimmer2009-01-30 08:18:38
User avatar
rasimmer
Posts: 182
Last visit: Fri Apr 25, 2014 7:00 am

Auto-scrolling HTA output

Post by rasimmer »

Thanks for the response, but that won't work in this situation. There has to be a way in IE to make the page scroll down as my output is posted to the page. I don't want to have to touch the scroll bar, I want to script it scrolling down so you can see what is going on in the HTA at that moment.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Auto-scrolling HTA output

Post by jvierra »

It just hit me that you are asking a vbscript question. This should be in teh vbscript forum.
To send keys to an application you need to first activate the application. This needs to havesome delay to be sure that the application has become teh "top most" app on the desktop. This is one reason why this technique can be so unreliable and why I suggest using the internal DHTML methods.
Her eis code that will activate an HTA and scroll down the item that currenty has focus. If your code or som event moves focus to some area like th frame or a button control this technique will never work. Again..this is why we usu8ally use the DHTML methods for UI control. "SendKeys" is a hangover from old DOS days and is maintained as it does have some uses.
Assuming that the title of your HTA is "MyHTA"

Code: Select all

Set oWSH = CreateObject("WScript.Shell")
oWSH.AppActivate "MyHTA" ' make top most app
WScript.Sleep 3000 ' wait for completion of activation
oWSH.SendKeys "{PGDN}"
WScript.Echo "Done"
User avatar
rasimmer
Posts: 182
Last visit: Fri Apr 25, 2014 7:00 am

Auto-scrolling HTA output

Post by rasimmer »

Thanks for the both the responses, but the first one is the one that looks like it's going to work for me as my data is being outputted to a <SPAN> and I need to scroll just the data in the span. The second post is basically what I was doing, but if I had the scriptHTA running in the background I just be sending PageDown to whatever application I was in. I could get around that by using AppActivate, but then it would pop on front of what I was doing too and be inhibiting my multi-tasking. I need the scrolling to take place in the application, simular to SMS Trace (Trace32.exe). I had started looking at the window.scroll methods to see of one of those would work, so I'll toss this in my HTA today and let you know if it's working like I want it too.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Auto-scrolling HTA output

Post by jvierra »

Look closely at teh HTASamples.zip examples.

1. Use a DIV in "body".
OR2. Add stule to body tag, give body an ID and scroll body.

If you post code please use "code" tags or upload as file as code connot be easily copied and pasted when stuck directly into post so I am not able to test your code.



jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Auto-scrolling HTA output

Post by jvierra »

Scrolling the whole window and all contents.

Just wrap everyting in a div. DIV must hav an explicit "height" set due to a bug/deficiency/feature in DHTML design.

Code: Select all

<html>
<head>
    <meta content="text/VBScript" http-equiv="content-script-type" />
    <title>HTA Sampler</title>
    <HTA:APPLICATION 
        ID="objMyHTA" 
        APPLICATIONNAME="MyHTA"
        SCROLL="no"
        SINGLEINSTANCE="yes"
        />
    <script language="vbscript">
    <!--
    
    Sub Window_OnLoad
        CenterWindow 520, 600
        for i = 1 to 40
           OutMsg2 i & " hello" 
        next
    End Sub
    
     Sub OutMsg2( msg )
        Div1.innerHTML = Div1.innerHTML  & msg & "<br/>"
        Div1.doScroll("pageDown")
    End Sub
    Sub CenterWindow( widthX, heightY )
        self.ResizeTo widthX, heightY 
        self.MoveTo (screen.Width - widthX)/2, (screen.Height - heightY)/2
    End Sub
        
 
    -->
    </script>
</head>
<body style="scroll:no;">
<div id="div1" style=" background-color:LightBlue; width: 100%; height: 400px; word-break:keep-all; overflow:auto">
</div>
</body>
This topic is 15 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked