Jump to content

Inputbox breaking...


Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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 ^.^
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...