Jump to content
Sign in to follow this  
Necromorph

username and password gui

Recommended Posts

Necromorph

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.

Share this post


Link to post
Share on other sites
somdcomputerguy

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


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Fulano

#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!

Share this post


Link to post
Share on other sites
Fulano

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!

Share this post


Link to post
Share on other sites
somdcomputerguy

I think it should read:

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

Yup. I was again not thinking about what I was typing..

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Fulano

::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!

Share this post


Link to post
Share on other sites
Necromorph

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

this works perfect, and it makes it case sensitive. so thanks to both of your for your help!!

Share this post


Link to post
Share on other sites
Fulano

Np, glad it works :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!

Share this post


Link to post
Share on other sites
spudw2k

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.

Share this post


Link to post
Share on other sites
Fulano

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!

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.