Re: Sleep until any keystroke



vdjatsuk@xxxxxxxxx wrote:
Dim StartTime, EndTime, input

StartTime = Time
EndTime = DateAdd("s", 2, Time)

Do Until StartTime=EndTime

WScript.echo "press enter"
do while not wscript.StdIn.AtEndofLine
input=input & wscript.StdIn.ReadLine
Loop
wscript.quit
Loop

Where and how should i add wscript.quit after the timer has been run?

On 23 май, 12:37, Jeffery Hicks <jhi...@xxxxxxxxxx> wrote:
vdjat...@xxxxxxxxx wrote:
Hi Jeffery,
Thanks for the help.
This is not exactly what i need. The script should be running timer
(wscript.sleep) for some 10 minutes and the any keystroke would break
the sleep and
it will start another command.
Best regards,
Vitali.
On 22 , 17:25, Jeffery Hicks <jhi...@xxxxxxxxxx> wrote:
vdjat...@xxxxxxxxx wrote:
Hi,
Could you please help me to write a script which makes wscript.sleep
until any keystroke.
This is my attempt:
Dim Input
Input = Input & WScript.StdIn.Read(1)
If input is TRUE then
wscript.quit
Else wscript.sleep 5000
End If
You need a loop like this:
Dim x
WScript.echo "Enter some text and press Enter twice:"
do while not wscript.StdIn.AtEndofLine
x=x & wscript.StdIn.ReadLine
Loop
WScript.echo "You entered " & x
wscript.quit
--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com
VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp
Windows PowerShell? -www.SAPIENPress.com/powershell.asp
blog:http://blog.SAPIEN.com
blog:http://jdhitsolutions.blogspot.com
In that case you can't use Wscript.Sleep What you might do is use
DateAdd to calculate a future time, how long you want to wait and create
an outer loop that runs until the current time matches the target time.
Within the loop, insert the Do While stdin example. Add a line to jump
to quit after the loop.

--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com
VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp
Windows PowerShell? -www.SAPIENPress.com/powershell.asp

blog:http://blog.SAPIEN.com
blog:http://jdhitsolutions.blogspot.com



I think by design that ReadLine for STDIN will sit and wait forever. That's why I asked if you really need to use STDIN. The one hack that comes to mind is to kick off a a WMI ansynch event sink watching the CSCript process and if the process lifetime exceeds a value, then terminate the process. This is a real hack and not one I can even guarantee will work. Sometimes we have to accept that some things just can't be scripted.

--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com
VBScript & Windows PowerShell Training - www.ScriptingTraining.com/classes.asp
Windows PowerShell? - www.SAPIENPress.com/powershell.asp

blog: http://blog.SAPIEN.com
blog: http://jdhitsolutions.blogspot.com
.



Relevant Pages

  • Re: Batch file to delete old profiles, cant figure out where to set the parameters or how to output
    ... goto:EOF ... SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com ... VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp ...
    (microsoft.public.scripting.wsh)
  • Re: How to make Internet Explorer window top most?
    ... > How to place Internet Explorer on top(modal window). ... You could set a title, and use AppActivate on it, an example here: ... You should add an "WScript.Sleep 100 in this loop to avoid CPU hogging. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windows.server.scripting)
  • Re: Damn you, FEDEX! or Nikon D40 lost in Springfield, MO blackhole.
    ... the 2 mp Mavica he had been using with a Nikon D40. ... After shopping around, he got me to order one for him. ... The shipper had it insured, but from what I have read it could take weeks to sort this crap out. ... You may get your insurance from FedEx and a couple weeks later they find it and deliver it. ...
    (alt.photography)
  • Re: readLine method help
    ... When I use your code without the if loop, it writes localhost into the document... ... dim fso, fl, count ... torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.scripting.vbscript)
  • Re: readLine method help
    ... Is there a way to make the cmd execution window not ... >> code without the if loop, it writes localhost into the document... ... > Set objStdOut = objWshScriptExec.StdOut ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.scripting.vbscript)