Re: WScript Sleep in HTML

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Tom Lavedas (lavedas_at_pressroom.com)
Date: 09/17/04


Date: Fri, 17 Sep 2004 11:55:08 -0400

Yes, setInterval is running asynchronusly. That's why your script needs
to be cut into two parts - to effect the pause. I believe the example I
posted does exactly that.

Using the ping is up to you, but the setInterval will also work.

Tom Lavedas
==============

Bruce Hensley wrote:
> Tom,
>
> Thanks for being so patient. I think I just got it! Please correct me if
> I'm wrong ...
>
> SetInterval starts executing the sub or function in its call on a repeating
> schedule, but it is done asynchronously; that is, immediately following the
> call to SetInterval, execution of the script continues with the next command
> after the SetInterval, while the SetInterval simultaneously continues to
> send its repeated calls.
>
> If so, this will not achieve my goal, which was to pause the script. The
> reason for pausing the script is that IE throws an "error" ("A script on
> this page is causing Internet Explorer to run slowly...") with the following
> code (which works fine from a VBS) ...
>
> do until oIE.readystate = 4
> loop
>
> I guess I'll stick with the Ping approach (which works even though it looks
> silly) ...
>
> 'wait til page is loaded
> Do until oIE.readystate=4
> Sleep 1
> Loop
>
> Sub Sleep(seconds)
> 'pause script about 1 second
> Set oWSShell = CreateObject("Wscript.Shell")
> cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul"
> oWSShell.Run cmd,0,1
> End Sub
>
> To not exactly answer your questions ... no, this is an HTML file that is
> closed after it runs. Its purpose is to load another slow-to-load page,
> wait for it to complete loading, then populate its form fields and submit
> it. I have had no security issues, but this is run from a trusted site in
> our intranet. I am not using an HTA or window.open or frame, because I
> didn't think of it ... being a newbie and all.
>
> Thanks again,
> Bruce
>
> "Tom Lavedas" <tlavedas@hotmail.com> wrote in message
> news:b86eca15.0409160901.1c341742@posting.google.com...
>
>>I know that this is a complicated subject. It took me a while to
>>figure out how to use it, too. The problem is that to have this work,
>>your calling subroutine must END after you set up the setInterval AND
>>then the called routine must call a new subroutine (or the old one
>>with a re-entry argument to control branching).
>>
>>For example ...
>>
>>' Declare global variables
>> Dim oIE
>> Dim Interval
>>' if this is to execute 'onload' your code/event will need to initiate
>>the
>>' FirstRoutine to set the ball rolling. But in either case, the
>>setInterval
>>' must be setup in the 'onload' code and then that routine must reach
>>its end.
>>
>>Sub FirstRoutine(arguments)
>> Set oIE = createobject("internetexplorer.application")
>> Interval = window.setinterval("WaitUntilReady", 100, "vbscript")
>> oIE.navigate "href of very slow page"
>>End sub
>>
>>Sub WaitUntilReady()
>> If (oIE.readystate = 4) then window.clearinterval Interval
>> ContinueRoutine ' or FirstRoutine with argument to branch to
>>second part
>>End Sub
>>
>>Sub ContinueRoutine
>>' The load is now complete
>> oIE.Visible = True
>>' now do the rest of the stuff
>>End Sub
>>
>>Hope that helps.
>>
>>BTW, is this in an HTA? I don't quite understand the logic of using
>>the IE.App object. It causes security issues in an HTML, doesn't it?
>>Why are you not using a frame or a window.open which is directly
>>supported by the DOM in both HTML and HTA?
>>
>>Tom Lavedas
>>==============
>>
>
>
>



Relevant Pages

  • Re: Logon HTA display not updating
    ... I have a HTA script that runs as a logon script. ... I use a textarea to display a timestamped message ... Sub Main ...
    (microsoft.public.scripting.vbscript)
  • Re: Detecting is hyperthreading is enabled with WMI?
    ... It is too bad that WMI does not give this info. ... have to be done to the script. ... Public Sub DisplayProcessorInfo ... dim ProcessorSet, Processor ...
    (microsoft.public.windowsxp.wmi)
  • Re: alternative to Wscript.Quit for use in HTA
    ... stop the script. ... How to I quit a vbscript inside a HTA. ... understand why I just want a way to stop the script running. ... I think what you want in that sub is "exit Sub", but frankly, I'm wondering ...
    (microsoft.public.scripting.vbscript)
  • Cant make this page work
    ... I can't make this script work properly. ... The script at the bottom of the html page ... Does someone have a perl ... sub output_trace_headers { ...
    (comp.lang.javascript)
  • Re: Maybe I should try a different approach
    ... entire time my script is running, then have it close when my script is done and maybe have some dots keep adding to the text message until the script is fully completed? ... ' The "Three Ugly Hack" Script, ... Sub oATO_vbTimerEvent' timer event handler... ... Public Property Let Left ...
    (microsoft.public.scripting.vbscript)