Jump to content
Sign in to follow this  
Ryuji5864

Inputbox breaking...

Recommended Posts

Ryuji5864

CODE

$LoopB = 1

While $LoopB = 1

$newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤")

$slen = StringLen($newpw)

If @error = 1 Then

$LoopB = 0

Send("{TAB}{TAB}{TAB}{TAB}{SPACE}")

sleep(550)

Send("{ALTDOWN}c{ALTUP}")

sleep(550)

send("{ENTER}")

sleep(550)

Send("{ALTDOWN}{F4}{F4}{ALTUP}")

exit

Else

If $slen < 7 AND $slen > 0 Then

MsgBox(4096, "Error", "Password is too short - try again!")

Else

$LoopB = 0

Send($newpw)

Send("{Tab}")

Send($newpw)

Send("{TAB}{TAB}{SPACE}")

Sleep(550)

Send("{ENTER}")

Sleep(550)

Send("{ALTDOWN}c{ALTUP}")

Sleep(550)

send("{ENTER}")

Send("{ALTDOWN}{F4}{F4}{ALTUP}")

EndIf

EndIf

WEnd

For some reason the Inputbox is breaking and I do not know how to fix it. When a user presses cancel its supposed to exit. When a user enters a password less than 7 characters, it is supposed to prompt them to enter a password again. If the password is >= 7 its supposed to change their password to the newly entered value.

I have tested the input box and when I press 'cancel' it changes their password. If the password is too short, it does prompt the user to re-enter a value. If they type in a password at least 7 characters or more it changes their password.

Edited by Ryuji5864

Share this post


Link to post
Share on other sites
Richard Robertson

You need to check @error before doing anything else. You checked the length of the string, which did not error, so @error was not set.

Also, you should not be checking for length greater than 0. You leave the open clause that the length may be zero and the program would skip right over your code. If someone hit OK with an empty box, you will set a blank password.

Share this post


Link to post
Share on other sites
Valuater

You were checking the error for the inputbox after stringlen(), this is a fix

While $LoopB = 1
    $newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤")
    $error = @error
    $slen = StringLen($newpw)
    If $error = 1 Then
        $LoopB = 0
        Send("{TAB}{TAB}{TAB}{TAB}{SPACE}")
        Sleep(550)
        Send("{ALTDOWN}c{ALTUP}")
        Sleep(550)
        Send("{ENTER}")
        Sleep(550)
        Send("{ALTDOWN}{F4}{F4}{ALTUP}")
        Exit
    Else
        If $slen < 7 And $slen > 0 Then
            MsgBox(4096, "Error", "Password is too short - try again!")
        Else
            $LoopB = 0
            Send($newpw)
            Send("{Tab}")
            Send($newpw)
            Send("{TAB}{TAB}{SPACE}")
            Sleep(550)
            Send("{ENTER}")
            Sleep(550)
            Send("{ALTDOWN}c{ALTUP}")
            Sleep(550)
            Send("{ENTER}")
            Send("{ALTDOWN}{F4}{F4}{ALTUP}")
        EndIf
    EndIf
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Ryuji5864

You need to check @error before doing anything else. You checked the length of the string, which did not error, so @error was not set.

Also, you should not be checking for length greater than 0. You leave the open clause that the length may be zero and the program would skip right over your code. If someone hit OK with an empty box, you will set a blank password.

My first if statement is @error = 1, which returns the 'Cancel' button was pushed. The only reason why I am checking that the length is greater than zero is because it is not exiting when the cancel button is pressed.

Share this post


Link to post
Share on other sites
Melba23

Ryuji5864,

Perhaps something like this:

While 1
    $newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤")
    $slen = StringLen($newpw)
    If $slen = 0 Then
        MsgBox(4096, "Error", "Please enter something - try again!")
    ElseIf $slen < 7 Then
        MsgBox(4096, "Error", "Password is too short - try again!")
    ElseIf $slen > 7 Then
        MsgBox(4096, "Error", "Password is too long - try again!")
    Else
        ConsoleWrite("Do It!" & @CRLF)
        #cs
            Send($newpw)
            Send("{Tab}")
            Send($newpw)
            Send("{TAB}{TAB}{SPACE}")
            Sleep(550)
            Send("{ENTER}")
            Sleep(550)
            Send("{ALTDOWN}c{ALTUP}")
            Sleep(550)
            Send("{ENTER}")
            Send("{ALTDOWN}{F4}{F4}{ALTUP}")
        #ce
        ExitLoop
    EndIf
WEnd

ConsoleWrite("Here" & @CRLF)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Ryuji5864

You were checking the error for the inputbox after stringlen(), this is a fix

$error = @error

Thanks a ton... I cannot believe it was that simple.

Share this post


Link to post
Share on other sites
Ryuji5864

Ryuji5864,

Perhaps something like this:

While 1
    $newpw = InputBox("Change Student's Password", "Please type in a seven digit password for the student's account:", "", "¤")
    $slen = StringLen($newpw)
    If $slen = 0 Then
        MsgBox(4096, "Error", "Please enter something - try again!")
    ElseIf $slen < 7 Then
        MsgBox(4096, "Error", "Password is too short - try again!")
    ElseIf $slen > 7 Then
        MsgBox(4096, "Error", "Password is too long - try again!")
    Else
        ConsoleWrite("Do It!" & @CRLF)
        #cs
            Send($newpw)
            Send("{Tab}")
            Send($newpw)
            Send("{TAB}{TAB}{SPACE}")
            Sleep(550)
            Send("{ENTER}")
            Sleep(550)
            Send("{ALTDOWN}c{ALTUP}")
            Sleep(550)
            Send("{ENTER}")
            Send("{ALTDOWN}{F4}{F4}{ALTUP}")
        #ce
        ExitLoop
    EndIf
WEnd

ConsoleWrite("Here" & @CRLF)

M23

I like the way you think ^.^

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.