Jump to content

username and password gui


Recommended Posts

ok i have this code, but it isn't working,

#INCLUDE <GUIConstantsEx.au3>

GUICREATE("redLabel password vault", 250, 225)
GUICTRLCREATELABEL("username", 25, 25)
$tUsername=GUICTRLCREATEINPUT("", 25, 50, 200)
GUICTRLCREATELABEL("password", 25, 100)
$tPassword=GUICTRLCREATEINPUT("", 25, 125, 200)
$tCancel=GUICTRLCREATEBUTTON("cancel", 75, 175, 75)
$tStart=GUICTRLCREATEBUTTON("login", 150, 175, 75)
GUISETSTATE()
GUICTRLSETSTATE($tStart, $GUI_DEFBUTTON)
WHILE 1
    $msg=GUIGETMSG()
        IF $msg=$GUI_EVENT_CLOSE THEN
            EXIT
        ELSEIF $msg=$tCancel THEN
            EXIT    
        ELSEIF $msg=$tStart THEN
            IF NOT GUICTRLREAD($tUsername="test" AND $tPassword="test") THEN
                MSGBOX(0, "redLabel password vault", "invalid username/password")
            ELSE
                MSGBOX(0, "redLabel password vault", "login sucsessful")
                GUISETSTATE(@SW_HIDE)
                EXITLOOP                
            ENDIF
        ENDIF
WEND

but it is always stuck even if the right username and password are entered. but if i put an exitloop after the "IF NOT" then after the msgbox, it ends, which i also don't want.

Link to comment
Share on other sites

#INCLUDE <GUIConstantsEx.au3>

GUICREATE("redLabel password vault", 250, 225)
GUICTRLCREATELABEL("username", 25, 25)
$tUsername=GUICTRLCREATEINPUT("", 25, 50, 200)
GUICTRLCREATELABEL("password", 25, 100)
$tPassword=GUICTRLCREATEINPUT("", 25, 125, 200)
$tCancel=GUICTRLCREATEBUTTON("cancel", 75, 175, 75)
$tStart=GUICTRLCREATEBUTTON("login", 150, 175, 75)
GUISETSTATE()
GUICTRLSETSTATE($tStart, $GUI_DEFBUTTON)
WHILE 1
    $msg=GUIGETMSG()
        IF $msg=$GUI_EVENT_CLOSE THEN
            EXIT
        ELSEIF $msg=$tCancel THEN
            EXIT    
        ELSEIF $msg=$tStart THEN
            IF NOT GUICTRLREAD($tUsername="test" AND $tPassword="test") THEN ;<- I think the problem is here
                MSGBOX(0, "redLabel password vault", "invalid username/password")
            ELSE
                MSGBOX(0, "redLabel password vault", "login sucsessful")
                GUISETSTATE(@SW_HIDE)
                EXITLOOP                
            ENDIF
        ENDIF
WEND

I think it should read:

IF GUICTRLREAD($tUsername) <> "test" AND GUICTRLREAD($tPassword) <> "test" THEN

Disclaimer: I can't test this at the moment, but it looks like that would create the problem you are having. This is what I think is happening:

Original Code:

1: IF NOT GUICTRLREAD($tUsername="test" AND $tPassword="test") THEN

Evaluation of inner statement:

2: IF NOT GUICTRLREAD(False AND False) THEN

Evaluation of (False AND False):

3: IF NOT GUICTRLREAD(False) THEN

GUICTRLREAD returns False, because 'False' isn't a valid control:

4: IF NOT False THEN

This is why it always gets stuck:

5: IF True Then

Edited for readability

Edited by Fulano

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

Try this. Change IF NOT GUICTRLREAD($tUsername="test" AND $tPassword="test") THEN to IF NOT GUICTRLREAD($tUsername) = "test" AND GUICTRLREAD($tPassword) = "test") THEN

An excess of parenthesis is almost never a bad thing.

AutoIt will read this as IF (NOT GUICTRLREAD($tUsername) = "test") AND GUICTRLREAD($tPassword) = "test") THEN, so it will fail on the correct username.

Side note: AutoIt scripts are really, really insecure, so definitely hash those passwords and usernames so you can't pull them out of the script

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

::Shrugs:: It happens to the best ... and me as well :mellow:

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
Share on other sites

quick lesson in security. DO NOT hardcode username or passwords in cleartext. Always use an encryption scheme (I strongly recommend a one-way hash) to protect authentication credentials. Now that you have a working form, do yourself a favor an research how to implement an encryption method rather than putting the user and pass in the code.

Link to comment
Share on other sites

quick lesson in security. DO NOT hardcode username or passwords in cleartext. Always use an encryption scheme (I strongly recommend a one-way hash) to protect authentication credentials. Now that you have a working form, do yourself a favor an research how to implement an encryption method rather than putting the user and pass in the code.

BUMP!

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

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...