Sign in to follow this  
Followers 0
IvanCodin

InputBox Timeout

3 posts in this topic

#1 ·  Posted (edited)

I cant seem to get the timeout to work. I want the user to be presented with a default value that can be changed or it will send the default value entered in the inputbox after the timeout. The Help shows some of the values as -1, what does this do?

Tried several variations of this.

$Server = InputBox("Server", "Enter you server name:", "192.168.1.1", " M", 220, 180, -1, -1, 5)

The help says:

InputBox ( "title", "prompt" [, "default" [, "password char" [, width [, height [, left [, top [, timeout [, hwnd]]]]]]]] )

$Server = InputBox("Server", "Enter you server name:", "192.168.1.1", " M", 220, 180, , , 5) <= This errors wrong syntax

$Server = InputBox("Server", "Enter you server name:", "192.168.1.1", " M", 220, 180, 0, 0, 5) < This errors also

I want it to timeout after 5 seconds and set $server value to the 192.168.1.1 default ip address.

Thanks

Me

Edited by IvanCodin

Share this post


Link to post
Share on other sites



You were correct with your first line. What you have to remember is that if the timeout is reached, $Server will be 0 since it was not assigned. If you use an InputBox(), remember to Exit or Return or ContinueLoop after that directly after that line

If @error = 1 Then Exit

Note that if the user inputs conforming text and presses OK, the @error value remains at 0, but if the timeout is reached, the @error is 2

$Default_Server = "192.168.1.1"
$Server = InputBox("Server", "Enter you server name:", $Default_Server, " M", 220, 180, -1, -1, 5)
Switch @error
    Case 0
        $Error = @error
        $Msg = "You pressed OK with a Valid String" & @LF & 'Server is...' & $Server
    Case 2
        $Server = $Default_Server   ;You must define $Server manually since timeout was reached
        $Error = @error
        $Msg = "The Timeout time was reached." & @LF & 'Server assigned to default...' & $Server
    Case Else
        Exit
EndSwitch

MsgBox(262208, $Error, $Msg)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0