From: "Dave "Crash" Dummy" on
If I want to delay something in a VBS script, I just use the "Sleep"
method, like:

wscript.sleep(5000)
MsgBox "At last!"

But that code won't work in a HTA script because there is no WScript
object. Is there an alternative equivalent I can use? I can kluge
together a delay using the setTimeout function, but that can get really
messy.
--
Crash

"When you want to fool the world, tell the truth."
~ Otto von Bismarck ~
From: Mayayana on
I think there's more than one way. I use this:


SH.Run("sleeper.vbs " & MSecs, , True)

....where SH is WScript.Shell, MSecs is number of
milliseconds, and sleeper.vbs is a VBS file in the
same folder, containing this code:

Dim Arg
on error resume next
Arg = WScript.Arguments(0)
wscript.sleep Arg


--
--
"Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
news:lFQbo.90644$xZ2.27486(a)newsfe07.iad...
| If I want to delay something in a VBS script, I just use the "Sleep"
| method, like:
|
| wscript.sleep(5000)
| MsgBox "At last!"
|
| But that code won't work in a HTA script because there is no WScript
| object. Is there an alternative equivalent I can use? I can kluge
| together a delay using the setTimeout function, but that can get really
| messy.
| --
| Crash
|
| "When you want to fool the world, tell the truth."
| ~ Otto von Bismarck ~


From: "Dave "Crash" Dummy" on
Mayayana wrote:
> I think there's more than one way. I use this:
>
>
> SH.Run("sleeper.vbs " & MSecs, , True)
>
> ...where SH is WScript.Shell, MSecs is number of
> milliseconds, and sleeper.vbs is a VBS file in the
> same folder, containing this code:
>
> Dim Arg
> on error resume next
> Arg = WScript.Arguments(0)
> wscript.sleep Arg

Thanks. I usually use the ASPtime component, but it requires
installing a DLL. It was written about 13 years ago, but still works
fine in 64 bit Windows 7. A code sample for HTA or HTM:

Set Stopwatch=CreateObject("ASPtime.time")
Stopwatch.pause 5 'time in seconds
MsgBox "At last!"

The stopwatch can also be used to time intervals. If you are interested,
it is available here: http://www.15seconds.com/component/pg000210.htm
or here if you don't want to go through the registration business:
http://crash.thedatalist.com/download/asptime.zip

I am kind of hoping to find a fully self contained way to insert delays in
HTA scripts.
--
Crash

Committed to the search for intraterrestrial intelligence.
From: mbyerley on
In an HTA, you can mix disciplines, so you could use JScript and the
setTimeout method...

"Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
news:lFQbo.90644$xZ2.27486(a)newsfe07.iad...
> If I want to delay something in a VBS script, I just use the "Sleep"
> method, like:
>
> wscript.sleep(5000)
> MsgBox "At last!"
>
> But that code won't work in a HTA script because there is no WScript
> object. Is there an alternative equivalent I can use? I can kluge
> together a delay using the setTimeout function, but that can get really
> messy.
> --
> Crash
>
> "When you want to fool the world, tell the truth."
> ~ Otto von Bismarck ~


From: "Dave "Crash" Dummy" on
mbyerley wrote:
> "Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
> news:lFQbo.90644$xZ2.27486(a)newsfe07.iad...
>> If I want to delay something in a VBS script, I just use the
>> "Sleep" method, like:
>>
>> wscript.sleep(5000) MsgBox "At last!"
>>
>> But that code won't work in a HTA script because there is no
>> WScript object. Is there an alternative equivalent I can use? I can
>> kluge together a delay using the setTimeout function, but that can
>> get really messy.

> In an HTA, you can mix disciplines, so you could use JScript and the
> setTimeout method...

I thought I said that. The trouble with setTimeout is that it will not
cause an inline pause in execution. Code immediately following the
setTimeout function will execute immediately. So what you have to do is
put all the code following the pause in a subroutine. If the pause is
part of another subroutine or in a loop waiting for some external event,
it is a real nightmare.

--
Crash

Atheism is a matter of faith, too.
 |  Next  |  Last
Pages: 1 2
Prev: ScriptB
Next: MS Newgroups disappearing?