Thanks,
Fred
http://groups.google.com/advanced_search
If you don't mind using a third-party control, then meadroid's
"scriptx" control has a sleep method:
http://www.meadroid.com/scriptx/about.asp
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
wscript object is not available because hta's are run from mshta.exe and not from
wscript.exe
write a sleep.vbs file with the sleep command in it and run it from your hta.
Giovanni.
--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
In addition to the other suggestions, if all you are doing is "sleeping" for
a time period to check on something in a loop, remember you can also use
javascript in the same HTA and as such you can use the setTimeout and
clearTimeout methods.
In an HTA, you can call J(ava)Script from VBscript and vice / versa.
Examples of setTimeout and clearTimeout methods.
http://www.w3schools.com/js/js_timing.asp
> Thanks,
>
> Fred
>
Or can I only call it from one of the html objects in my code? Like in an
onclick or other event?
Thanks,
Fred
********begin Code**********
<html>
<HEAD>
<TITLE>This is the Application Caption</TITLE>
<SCRIPT type="text/jscript">
// Always Set Size Here to Avoid Flicker
var iwidth = 480;
var iheight = 400
window.moveTo( (window.screen.width - iwidth)/ 2, (window.screen.height -
iheight)/ 2);
window.resizeTo(iwidth,iheight);
</SCRIPT>
<HTA:APPLICATION ID="oApp"
APPLICATIONNAME="Splash Screen"
BORDER="thick"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
CAPTION="YES"
ICON="C:\Program Files\RBTI\RBG7\Samples\Icons\win1.ico"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
SCROLL="NO"
WINDOWSTATE="normal">
<script type="text/vbscript">
function CloseQuestion()
if msgbox("Should I Close This Window?", vbYesNo, "HTA - CloseOrNot") = vbYes
then
JSFunc("Quitting Now!")
end if
end function
Sub CallItQuits()
'Set SomeObjectCreated=Nothing
'Set SomeOtherObjectCreated=Nothing
'Set AnyObjectCreatedStillInstantiated=Nothing
window.Close()
end sub
</script>
<SCRIPT type="text/jscript">
function JSFunc(valIN)
{
alert(valIN);
CallItQuits();
}
</SCRIPT>
</HEAD>
<body >
<input type="button" value="How To Close HTA" onclick="CloseQuestion()">
</body>
</html>
*******End code*********
> Thanks,
>
> Fred
>
--
Joe Fawcett (MVP - XML)
So he goes to a J(ava)Script group and asks the inverse and gets the same
answer.
It would have been appropriate to just answer the question, since most of his
subject matter related to VBScript and HTA. "Anyone" could give your response.
>
>
Thanks,
Fred
Woops. Sorry. I misread, thinking you had
asked for javascript in the first place.
I use the same method Reventlov mentioned. It
shells to a separate script, allowing you use
Sleep in an HTA. It works because the last
parameter of Run (True) causes your script
to wait until the call returns.
This is called from the HTA or from an included
VBS file:
'--------------------------------
Sub Sleep1(MSecs)
Dim SH, Ret
On Error Resume Next
Set SH = CreateObject("WScript.Shell")
Ret = SH.Run("sleeper.vbs " & MSecs, , True)
If (Ret <> 0) Then
MsgBox "Possible problem with Sleep Function. Make sure
sleeper.vbs is in utility folder.", 64
End If
End Sub
'--------------------------------
You call it like so: Sleep1 5000 '-- 5 second pause.
Then you have a file named sleeper.vbs in the
same folder with the HTA. The entire content
of sleeper.vbs is this:
'---------------------
Dim Arg
on error resume next
Arg = WScript.Arguments(0)
wscript.sleep Arg
'---------------------
Thanks,
Fred
Yes, it's remarkable how much can be done with
script, but much of it is pretty ugly. :)