Sign in to follow this  
Followers 0
Jewtus

Dual credential login issues

6 posts in this topic

I've been trying to adapt this to my needs but I'm not sure what I'm doing wrong

'?do=embed' frameborder='0' data-embedContent>>

#include <GUIConstantsEx.au3>

; First Login
$GUI = GUICreate("Login", 210, 160, -1, -1, 0x16C80000, 0x00000181)
$USERNAME = GUICtrlCreateInput("First Username", 5, 5, 200, 20, 0x01)
$PASSWORD = GUICtrlCreateInput("First Password", 5, 30, 200, 20, 0x21)
$USERNAMESecond = GUICtrlCreateInput("Second Username", 5, 65, 200, 20, 0x01)
$PASSWORDSecond = GUICtrlCreateInput("Second Password", 5, 90, 200, 20, 0x21)
$LOGIN = GUICtrlCreateButton("Login", 50, 140, 100, 20)
GUISetState(@SW_SHOW, $GUI)


Local $LoggedIn
While Not $LoggedIn
    $MSG = GUIGetMsg()
    If $MSG = $LOGIN Then
        If GUICtrlRead($USERNAME) <> "" And GUICtrlRead($PASSWORD) <> "" And GUICtrlRead($USERNAMESecond) <> "" And GUICtrlRead($PASSWORDSecond) <> "" Then
            $LoggedIn = TRUE
            GUIDelete($GUI)
        Else
            MsgBox(0, "Login", "Username or password cannot be blank.")
        EndIf
    ElseIf $MSG = -3 Then
        Exit
    EndIf
    Sleep(20)
WEnd

MsgBox(0,"Login data", "First login is " & $USERNAME & " and the password is " & $PASSWORD)
MsgBox(0,"Login data", "Second login is " & $USERNAMESecond & " and the password is " & $PASSWORDSecond)

When I run this, it says the "First login is 3 and the password is 4" and "Second login is 5 and the password is 6"

I expect it to show what I entered into the GUI in the msg box, but its using numbers instead. What am I doing wrong and how do I make it pass through what I've typed?

Share this post


Link to post
Share on other sites



Use GUICtrlRead on the controls and not the variables assigned to them.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I tried this: 

MsgBox(0,"Login data", "Second login is " & GUICtrlRead($USERNAME) & " and the password is " & GUICtrlRead($PASSWORD))

and it kept kicking up "Second login is 0 and the password is 0"

Then I moved 

GUIDelete($GUI)

out of the loop and put it at the end and it seemed to work.

I'm trying to make this GUI pop up and save the username and password to variable. Is there a way to preserve the variable after I delete the GUI?

Share this post


Link to post
Share on other sites

Save them before you delete the GUI and use those variables in your MsgBoxs.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

When I try this: 

$UN1=GUICtrlRead($USERNAME) 
$PW1=GUICtrlRead($PASSWORD)
GUIDelete($GUI)
MsgBox(0,"Login data", "Second login is " & $UN1 & " and the password is " & $PW1))

I get the 0s again. Is there a different way of saving a variable?

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>

; First Login
$GUI = GUICreate("Login", 210, 160, -1, -1, 0x16C80000, 0x00000181)
$USERNAME = GUICtrlCreateInput("First Username", 5, 5, 200, 20, 0x01)
$PASSWORD = GUICtrlCreateInput("First Password", 5, 30, 200, 20, 0x21)
$USERNAMESecond = GUICtrlCreateInput("Second Username", 5, 65, 200, 20, 0x01)
$PASSWORDSecond = GUICtrlCreateInput("Second Password", 5, 90, 200, 20, 0x21)
$LOGIN = GUICtrlCreateButton("Login", 50, 140, 100, 20)
GUISetState(@SW_SHOW, $GUI)

Dim $saved_un1, $saved_un2, $saved_pw1, $saved_pw2


Local $LoggedIn
While Not $LoggedIn
    $MSG = GUIGetMsg()
    If $MSG = $LOGIN Then
        If GUICtrlRead($USERNAME) <> "" And GUICtrlRead($PASSWORD) <> "" And GUICtrlRead($USERNAMESecond) <> "" And GUICtrlRead($PASSWORDSecond) <> "" Then
            $saved_un1 = GUICtrlRead($USERNAME)
            $saved_un2 = GUICtrlRead($USERNAMESecond)
            $saved_pw1 = GUICtrlRead($PASSWORD)
            $saved_pw2 = GUICtrlRead($PASSWORDSecond)
            $LoggedIn = TRUE
            GUIDelete($GUI)
        Else
            MsgBox(0, "Login", "Username or password cannot be blank.")
        EndIf
    ElseIf $MSG = -3 Then
        Exit
    EndIf
    Sleep(20)
WEnd

MsgBox(0,"Login data", "First login is " & $saved_un1 & " and the password is " & $saved_pw1)
MsgBox(0,"Login data", "Second login is " & $saved_un2 & " and the password is " & $saved_pw2)


How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

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