Announcement

Collapse
No announcement yet.

How to wait a certain amount of time for user input then continue regardless

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to wait a certain amount of time for user input then continue regardless

    I know there's got to be a way but I don't know it and I can't find it.

    What I'm looking for is a vbs script that will give the user a popup:
    - if user clicks OK do A
    - if user doesn't click OK and n time has passed do B

    Any help would be great.

    edit: I know I could use choice.exe in a batch script but I was hoping to use a msgbox so I could have it display in front of all the windows.
    Last edited by JeremyW; 10th December 2008, 04:28.
    Regards,
    Jeremy

    Network Consultant/Engineer
    Baltimore - Washington area and beyond
    www.gma-cpa.com

  • #2
    Re: How to wait a certain amount of time for user input then continue regardless

    Well the vbok click thingie
    http://www.w3schools.com/VBScript/func_msgbox.asp
    http://wsh2.uw.hu/ch06c.html

    With WScript.Sleep time can you create a pause

    you can do then something like this:

    Code:
    result = MsgBox("Please click ok to install bla", vbQuestion + vbOK, "Testtitle")
    wscript.sleep 5
    
    If result = false then
    do function b
    else do function A
    end if
    It's quite a basic code and I'm very sure Rems can create a far better script.
    However this might work, only thing is, it also will wait 5 seconds if the user has clicked on ok.
    (damn I'm loosing my scripting skills)
    Marcel
    Technical Consultant
    Netherlands
    http://www.phetios.com
    http://blog.nessus.nl

    MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
    "No matter how secure, there is always the human factor."

    "Enjoy life today, tomorrow may never come."
    "If you're going through hell, keep going. ~Winston Churchill"

    Comment


    • #3
      Re: How to wait a certain amount of time for user input then continue regardless

      i think it's more like this , waiting time is five seconds :

      Code:
      Set WshShell = WScript.CreateObject("WScript.Shell")
      
      BtnCode = WshShell.Popup("How Do You Feel?", 5, "Good Morning:", 0 + 48)
      
      Select Case BtnCode
         case 1      
         WScript.Echo "Ok Pressed."
         case -1     
         WScript.Echo "Is there anybody out there?"
      End Select
      if you want to add cancel option
      Code:
      Set WshShell = WScript.CreateObject("WScript.Shell")
      
      BtnCode = WshShell.Popup("How Do You Feel?", 5, "good morning:", 1 + 48)
      
      Select Case BtnCode
         case 1      
         WScript.Echo "Ok Pressed."
         Case 2
         WScript.Echo "cancel Pressed."
         case -1     
         WScript.Echo "Is there anybody out there?"
      End Select
      Last edited by largo; 10th December 2008, 13:53.
      Any advice is given in good faith and without warranty.
      Please give reputation points where appropriate.

      Comment


      • #4
        Re: How to wait a certain amount of time for user input then continue regardless

        Thanks largo, that is exactly what I'm looking for!

        Marcel, the method you said waits for user input and then will to the sleep. But thanks for the suggestion. (I probably didn't explain myself very well)
        Regards,
        Jeremy

        Network Consultant/Engineer
        Baltimore - Washington area and beyond
        www.gma-cpa.com

        Comment


        • #5
          Re: How to wait a certain amount of time for user input then continue regardless

          Originally posted by JeremyW View Post
          What I'm looking for is a vbs script that will give the user a popup:
          - if user clicks OK do A
          - if user doesn't click OK and n time has passed do B
          Good answers already provided.
          The basic is that you just need to define a variable for the returned code value. Then you can discover the exact code value for each button by your self by echoing the variable after the message box is closed.
          Or, refer these sites:
          - VBS MsgBox Function
          - WSH Popup Method
          - Mother, May I? ...The VBScript MsgBox function and the Windows Script Host (WSH) Popup method takes parameters that define what the message box or popup box will look like, and it returns a value we can use to determine which button was clicked.

          To "to wait a certain amount of time for user input " you should use the Popup method.
          To "display in front of all the windows" add vbSystemModal to the window type.


          \Rems

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment


          • #6
            Re: How to wait a certain amount of time for user input then continue regardless

            Well, glad there are others who keeping there scripting skills.
            I rather play with network security
            Marcel
            Technical Consultant
            Netherlands
            http://www.phetios.com
            http://blog.nessus.nl

            MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
            "No matter how secure, there is always the human factor."

            "Enjoy life today, tomorrow may never come."
            "If you're going through hell, keep going. ~Winston Churchill"

            Comment

            Working...
            X