Re: WScript Sleep in HTML
From: Tom Lavedas (lavedas_at_pressroom.com)
Date: 09/17/04
- Next message: Baruch Mettler: "Re: Problems running remote batch copy from wshshell asp script"
- Previous message: Bruce Hensley: "Re: WScript Sleep in HTML"
- In reply to: Bruce Hensley: "Re: WScript Sleep in HTML"
- Next in thread: mayayana: "Re: WScript Sleep in HTML"
- Messages sorted by: [ date ] [ thread ]
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
>>==============
>>
>
>
>
- Next message: Baruch Mettler: "Re: Problems running remote batch copy from wshshell asp script"
- Previous message: Bruce Hensley: "Re: WScript Sleep in HTML"
- In reply to: Bruce Hensley: "Re: WScript Sleep in HTML"
- Next in thread: mayayana: "Re: WScript Sleep in HTML"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|