Jump to content
Sign in to follow this  
TheOnlyOne

help with input box and readfile

Recommended Posts

TheOnlyOne

cant see that i did wrong it should first ask about username and then password then should it write it to a file i made and then ask about username and password and it should get it from the 2 files i made ?

but it allways say its wrong

help?

my script:

$username = InputBox("Security Check", "sellect your username.", "......", "")
$passwd   = InputBox("Security Check", "sellect your password.", "......", "*")
$file    = FileOpen("username.txt", 1)
$file2  = FileOpen("password.txt", 1)
FileWrite ($file,$username)
FileWrite ($file2,$passwd)
sleep (5000)
$chars  = FileRead($file, 1)
$chars2   = FileRead($file2, 1)
sleep (500)


$check1   = InputBox("Security Check", "Enter your username.", "......", "")
$check2   = InputBox("Security Check", "Enter your password.", "......", "*")
if $check1=$chars then      msgbox (0,"","LOADING")
if $check1=$chars=false then  msgbox (0,"","username is wrong")
if $check2=$chars2 then    msgbox (0,"","LOADING")
if $check2=$chars2=false then msgbox (0,"","password is wrong")
Edited by TheOnlyOne

Share this post


Link to post
Share on other sites
Melba23

TheOnlyOne,

A few things wrong there:

1. You were not deleting the files when you exited, so each run was adding the new username/password to the old file. You will never get a match that way!

2. You were only reading in 1 character from each file. Read the Help file again to check on the parameters. Again a match was pretty unlikely!

3. Your checks were a bit all over the place. I have written a new version which I hope is clearer.

4. Finally, I noticed that you opened, but did not close, your files. Autoit will close them automatically, but it is good practice to do it yourself. For small scripts like this, it is probably better to use the path rather than the handle and let Autoit do everything for you.

Look at this code, it works for me:

$username = InputBox("Security Check", "select your username.", "......", "")
$passwd   = InputBox("Security Check", "select your password.", "......", "*")
$file1  = "username.txt"
$file2  = "password.txt"
FileWrite ($file1, $username)
FileWrite ($file2, $passwd)

sleep (500)

$chars1 = FileRead($file1)
$chars2   = FileRead($file2)
sleep (500)


$check1   = InputBox("Security Check", "Enter your username.", "......", "")
$check2   = InputBox("Security Check", "Enter your password.", "......", "*")
if $check1 = $chars1 then
    if $check2 = $chars2 Then
        msgbox (0,"","LOADING")
    Else
        msgbox (0,"","password is wrong")
    EndIf
Else
    msgbox (0,"","username is wrong")
EndIf

FileDelete($file1)
FileDelete($file2)

Ask if anything is unclear.

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
TheOnlyOne

TheOnlyOne,

A few things wrong there:

1. You were not deleting the files when you exited, so each run was adding the new username/password to the old file. You will never get a match that way!

2. You were only reading in 1 character from each file. Read the Help file again to check on the parameters. Again a match was pretty unlikely!

3. Your checks were a bit all over the place. I have written a new version which I hope is clearer.

4. Finally, I noticed that you opened, but did not close, your files. Autoit will close them automatically, but it is good practice to do it yourself. For small scripts like this, it is probably better to use the path rather than the handle and let Autoit do everything for you.

Look at this code, it works for me:

$username = InputBox("Security Check", "select your username.", "......", "")
$passwd   = InputBox("Security Check", "select your password.", "......", "*")
$file1  = "username.txt"
$file2  = "password.txt"
FileWrite ($file1, $username)
FileWrite ($file2, $passwd)

sleep (500)

$chars1 = FileRead($file1)
$chars2   = FileRead($file2)
sleep (500)


$check1   = InputBox("Security Check", "Enter your username.", "......", "")
$check2   = InputBox("Security Check", "Enter your password.", "......", "*")
if $check1 = $chars1 then
    if $check2 = $chars2 Then
        msgbox (0,"","LOADING")
    Else
        msgbox (0,"","password is wrong")
    EndIf
Else
    msgbox (0,"","username is wrong")
EndIf

FileDelete($file1)
FileDelete($file2)

Ask if anything is unclear.

M23

okay that works but it should not delete the file it should store them so when there is 20 passwords and 20 usernames (and they need to match) it should check about the username is in the text file and the password match with the username ? how can i do that? (sorry for some bad english)

Share this post


Link to post
Share on other sites
Melba23

TheOnlyOne,

You will need to seriously change the structure of your code if that is what you want to do.

I would suggest something like this pseudo-code (that means a logic flow and not real AutoIt code!):

Open a GUI with 2 buttons; "Register" and "LogIn"

"Register" will allow the user to enter a username and password. You will have to make sure that you save these as different files to those already created.

"LogIn" will let the user enter a user name and password.

You will then have to loop through all the usernames and see if the name exists.

If it does then you will have to check the corresponding password.

If all checks out - then you can start whatever it is you want to run!

So you can see there is a bit more to do yet. Do not give up hope - it is not very difficult. Try and write a flow diagram to help you as you work out what to do in your code. If you run into problems (and you will!) read the help file carefully. It is a real goldmine if you take the trouble to look.

If you get really stuck come back to these forums. But make sure you have some code you have produced yourself - help is always given to those who have tried to do something for themselves, but just asking for the code to be written for you will not make you many friends. :-)

Good luck.

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
TheOnlyOne

TheOnlyOne,

You will need to seriously change the structure of your code if that is what you want to do.

I would suggest something like this pseudo-code (that means a logic flow and not real AutoIt code!):

Open a GUI with 2 buttons; "Register" and "LogIn"

"Register" will allow the user to enter a username and password. You will have to make sure that you save these as different files to those already created.

"LogIn" will let the user enter a user name and password.

You will then have to loop through all the usernames and see if the name exists.

If it does then you will have to check the corresponding password.

If all checks out - then you can start whatever it is you want to run!

So you can see there is a bit more to do yet. Do not give up hope - it is not very difficult. Try and write a flow diagram to help you as you work out what to do in your code. If you run into problems (and you will!) read the help file carefully. It is a real goldmine if you take the trouble to look.

If you get really stuck come back to these forums. But make sure you have some code you have produced yourself - help is always given to those who have tried to do something for themselves, but just asking for the code to be written for you will not make you many friends. :-)

Good luck.

M23

okay im back until now i made this

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$3=0
#Region ### START Koda GUI section ### Form=c:\documents and settings\lo\skrivebord\form2.kxf
$Form1_1 = GUICreate("Form1", 628, 299, 193, 125)
GUISetBkColor(0xA6CAF0)
$register = GUICtrlCreateButton("", 24, 24, 186, 71, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon.bmp", 0)

$login = GUICtrlCreateButton("", 24, 112, 184, 77, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login!.bmp", 0)



 GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$press= GUIGetMsg()
Switch $press
Case $GUI_EVENT_CLOSE
Exit

Case $3
EndSwitch
if $press = $login Then

$Form2 = GUICreate("Login", 360, 329, 193, 125,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetBkColor(0xA6CAF0)
GUICtrlCreateInput("", 24, 40, 265, 19)
GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
$Label1 = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
GUICtrlCreateInput("", 24, 96, 265, 19)
GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
GUICtrlSetColor(-1, 0x800000)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
$Label2 = GUICtrlCreateLabel("Password", 24, 72, 82, 17)
$loginButton1 = GUICtrlCreateButton("(Not allowed)", 24, 136, 158, 37, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login2.bmp", 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

endif
if $press =$register then
GUISetState(@SW_hide,$Form1_1)
    $Form3 = GUICreate("register", 308, 220, 178, 116,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetBkColor(0xA6CAF0)
$chooseusername= GUICtrlCreateInput("", 32, 56, 241, 21)
$Label1 = GUICtrlCreateLabel("Choose your username.", 32, 32, 163, 16)
GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
$Label2 = GUICtrlCreateLabel("Choose your password.", 33, 111, 162, 16)
GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
$choosepassword=GUICtrlCreateInput("", 30, 131, 241, 21)
$registerButton1 = GUICtrlCreateButton("(Not allowed)", 40, 168, 67, 20, $BS_BITMAP, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon-small.bmp", 0)
$backButton = GUICtrlCreateButton("(Not allowed)", 176, 168, 65, 22, $BS_BITMAP, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\back.bmp", 0)
GUISetState(@SW_SHOW)

if $press =$backButton then 
        GUISetState(@SW_SHOW,$Form1_1)
            GUISetState(@SW_hide,$Form3)
        endif
endif

    





WEnd

but i got one problem

its the last lines this

if $press =$backButton then 
GUISetState(@SW_SHOW,$Form1_1)
GUISetState(@SW_hide,$Form3)
endif

there not happend somethink when i click backbutton why not ? i read in the help file like you told me to :) but could not find somethink there could help me with this (after looking in 30 min i gave up...)

Share this post


Link to post
Share on other sites
Melba23

TheOnlyOne,

Well done. That is just the sort of thing I was hoping you would produce.

A couple of points (look below to see how I changed your code):

1. You can use Switch to test all of the possible values for $press.

2. You need to run a loop for each of the small GUIs - how else are you going to see the button presses in them?

But your code is good start. Here is a slightly revised version:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\lo\skrivebord\form2.kxf
$Form1_1 = GUICreate("Form1", 628, 299, 193, 125)
    GUISetBkColor(0xA6CAF0)
$register = GUICtrlCreateButton("Register", 24, 24, 186, 71, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon.bmp", 0)
$login = GUICtrlCreateButton("LogIn", 24, 112, 184, 77, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login!.bmp", 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $press= GUIGetMsg()
    Switch $press
        Case $GUI_EVENT_CLOSE
            Exit
        Case $login
            $Form2 = GUICreate("Login", 360, 329, 193, 125,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
                GUICtrlCreateInput("", 24, 40, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label1 = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
                GUICtrlCreateInput("", 24, 96, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label2 = GUICtrlCreateLabel("Password", 24, 72, 82, 17)
            $loginButton1 = GUICtrlCreateButton("(Not allowed)", 24, 136, 158, 37, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login2.bmp", 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###
            
            While 1
                Switch GUIGetMsg()
                    Case $loginButton1
                        GUISetState(@SW_SHOW,$Form1_1)
                        GUISetState(@SW_hide,$Form2)
                        ExitLoop
                EndSwitch
            WEnd

        Case $register
            GUISetState(@SW_hide,$Form1_1)
            $Form3 = GUICreate("register", 308, 220, 178, 116,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
            $chooseusername= GUICtrlCreateInput("", 32, 56, 241, 21)
            $Label1 = GUICtrlCreateLabel("Choose your username.", 32, 32, 163, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $Label2 = GUICtrlCreateLabel("Choose your password.", 33, 111, 162, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $choosepassword=GUICtrlCreateInput("", 30, 131, 241, 21)
            $registerButton1 = GUICtrlCreateButton("Register", 40, 168, 67, 20, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon-small.bmp", 0)
            $backButton = GUICtrlCreateButton("Back", 176, 168, 65, 22, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\back.bmp", 0)
            GUISetState(@SW_SHOW)
            
            While 1
                Switch GUIGetMsg()
                    Case $backButton 
                        GUISetState(@SW_SHOW,$Form1_1)
                        GUISetState(@SW_hide,$Form3)
                        ExitLoop
                    Case $registerButton1 
                EndSwitch
            WEnd
    EndSwitch
WEnd

Make sure you understand why and how I have changed things. Ask if you are not clear.

Looking forward to the next version with some file saving and reading code!

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
TheOnlyOne

TheOnlyOne,

Well done. That is just the sort of thing I was hoping you would produce.

A couple of points (look below to see how I changed your code):

1. You can use Switch to test all of the possible values for $press.

2. You need to run a loop for each of the small GUIs - how else are you going to see the button presses in them?

But your code is good start. Here is a slightly revised version:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\lo\skrivebord\form2.kxf
$Form1_1 = GUICreate("Form1", 628, 299, 193, 125)
    GUISetBkColor(0xA6CAF0)
$register = GUICtrlCreateButton("Register", 24, 24, 186, 71, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon.bmp", 0)
$login = GUICtrlCreateButton("LogIn", 24, 112, 184, 77, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login!.bmp", 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $press= GUIGetMsg()
    Switch $press
        Case $GUI_EVENT_CLOSE
            Exit
        Case $login
            $Form2 = GUICreate("Login", 360, 329, 193, 125,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
                GUICtrlCreateInput("", 24, 40, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label1 = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
                GUICtrlCreateInput("", 24, 96, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label2 = GUICtrlCreateLabel("Password", 24, 72, 82, 17)
            $loginButton1 = GUICtrlCreateButton("(Not allowed)", 24, 136, 158, 37, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login2.bmp", 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###
            
            While 1
                Switch GUIGetMsg()
                    Case $loginButton1
                        GUISetState(@SW_SHOW,$Form1_1)
                        GUISetState(@SW_hide,$Form2)
                        ExitLoop
                EndSwitch
            WEnd

        Case $register
            GUISetState(@SW_hide,$Form1_1)
            $Form3 = GUICreate("register", 308, 220, 178, 116,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
            $chooseusername= GUICtrlCreateInput("", 32, 56, 241, 21)
            $Label1 = GUICtrlCreateLabel("Choose your username.", 32, 32, 163, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $Label2 = GUICtrlCreateLabel("Choose your password.", 33, 111, 162, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $choosepassword=GUICtrlCreateInput("", 30, 131, 241, 21)
            $registerButton1 = GUICtrlCreateButton("Register", 40, 168, 67, 20, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon-small.bmp", 0)
            $backButton = GUICtrlCreateButton("Back", 176, 168, 65, 22, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\back.bmp", 0)
            GUISetState(@SW_SHOW)
            
            While 1
                Switch GUIGetMsg()
                    Case $backButton 
                        GUISetState(@SW_SHOW,$Form1_1)
                        GUISetState(@SW_hide,$Form3)
                        ExitLoop
                    Case $registerButton1 
                EndSwitch
            WEnd
    EndSwitch
WEnd

Make sure you understand why and how I have changed things. Ask if you are not clear.

Looking forward to the next version with some file saving and reading code!

M23

okay thanks a lot now i come to where i need to save the code and read it and save it is not so hard but i have the problem with when it gonna search for it ? and im not sure but should i use SRE? for i dont really understand that command so can you plz ekplain to me how to use it if i need to use this command :S?

my file wright now

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:\documents and settings\lo\skrivebord\form2.kxf
$Form1_1 = GUICreate("Form1", 628, 299, 193, 125)
    GUISetBkColor(0xA6CAF0)
$register = GUICtrlCreateButton("Register", 24, 24, 186, 71, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon.bmp", 0)
$login = GUICtrlCreateButton("LogIn", 24, 112, 184, 77, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login!.bmp", 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $press= GUIGetMsg()
    Switch $press
        Case $GUI_EVENT_CLOSE
            Exit
        Case $login
            $Form2 = GUICreate("Login", 360, 329, 193, 125,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
                GUICtrlCreateInput("", 24, 40, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label1 = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
                GUICtrlCreateInput("", 24, 96, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label2 = GUICtrlCreateLabel("Password", 24, 72, 82, 17)
            $loginButton1 = GUICtrlCreateButton("(Not allowed)", 24, 136, 158, 37, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login2.bmp", 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###
            
            While 1
                Switch GUIGetMsg()
                    Case $loginButton1
                        GUISetState(@SW_SHOW,$Form1_1)
                        GUISetState(@SW_hide,$Form2)
                        ExitLoop
                EndSwitch
            WEnd

        Case $register
            GUISetState(@SW_hide,$Form1_1)
            $Form3 = GUICreate("register", 308, 220, 178, 116,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
            $chooseusername= GUICtrlCreateInput("", 32, 56, 241, 21)
            $Label1 = GUICtrlCreateLabel("Choose your username.", 32, 32, 163, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $Label2 = GUICtrlCreateLabel("Choose your password.", 33, 111, 162, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $choosepassword=GUICtrlCreateInput("", 30, 131, 241, 21)
            $registerButton1 = GUICtrlCreateButton("Register", 40, 168, 67, 20, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon-small.bmp", 0)
            $backButton = GUICtrlCreateButton("Back", 176, 168, 65, 22, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\back.bmp", 0)
            GUISetState(@SW_SHOW)
            
            While 1
                Switch GUIGetMsg()
                    Case $backButton 
                        GUISetState(@SW_SHOW,$Form1_1)
                        GUISetState(@SW_hide,$Form3)
                        ExitLoop
                    Case $registerButton1
                    $username=GUICtrlRead($chooseusername)
                        $password=GUICtrlRead($choosepassword)
                        FileWrite ("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$username)
                        FileWrite ("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$password)
                        
                EndSwitch
                
            WEnd
    EndSwitch
WEnd
Edited by TheOnlyOne

Share this post


Link to post
Share on other sites
Melba23

TheOnlyOne,

Firstly, please do NOT use the '"Reply button' - use the '+ Add Reply' button when posting. We do not need to see a copy of the previous post - these threads get long enough as it is! :-)

Now, do you remember what I wrote in response to your first question? If you just save the username and password like this:

FileWrite ("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$username)
FileWrite ("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$password)

you will overwrite or add to the file each time and you will not be able to search for the username/password later on.

Here is a hint. Look at FileReadToArray and FileWriteFromArray. These functions allow you to add as many usernames/passwords as you want to a file - and get them back again in an easy-to-search format. Go and play with them for a bit and then show me how you think you might use them - use pseudo-code if you want to (look back at the first thread to see what I mean!).

You are doing well - do NOT get discouraged. If I am making you do the work it is because it helps you develop skills that are worth having - logic (to work out what you have to do), perseverance (to spend time trying to get your code working), accuracy (the reason most programs fail at the first run), humility (no-one ever gets it all right all of the time!) and most of patience (I have been coding on and off for 40 years and still get frustrated from time to time).

So, go and read the Help file, play with those 2 functions and come back when you think you have something - or you are really stuck! And I do not mean in 5 minutes. ;-)

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
TheOnlyOne

yeah i know you just wanna help me with being better :)

but im allready stuck ....

its agian when trying to save that you set in to the input box there is nothink happending. here is where the problem

$username=GUICtrlRead($chooseusername)
$password=GUICtrlRead($choosepassword)

_FileWriteFromArray ($1,$chooseusername,0,0)
_FileWriteFromArray ($2,$choosepassword,0,0)
if @error Then  msgbox (0,"",@error)

i set in a msgbox there says what error it is and it says its @error 2 and in the help file there stand its becus its not a array... then i was going to the help file looking for array but cant find anythink there macking it to an array. so how can i make it to and array ? for cant really not find it

sorry for allready comeing back...

Share this post


Link to post
Share on other sites
Manjish

i think that this whole concept has been made too complicated.. there always exists a simple solution..

here it is..

whenever u want to register any username and password, just simply write it in a single ini file.. like this

username=password

u can write as many such username and password pairs..

Then u can tally any entered login username and password, to the keys contained in this ini file..

just check if the value of key is same as password entered..

n if u don't find the key.. u can say.. its an invalid username..

if the value is a mismatch.. say its an invalid password..

what's the need to complicate it so much..???


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites
Melba23

TheOnlyOne,

If you want a variable to act as an array you have to declare it. Good places in the Help file to read about arrays are Language Reference - Variables and Keyword/Statement Reference - Dim

In your code GUICtrlRead returns a simple variable - not an array. So _FileWriteFromArray gives you the error.

What you could do is to declare 2 arrays at the beginning of your script and then add the new username/password to them using _ArrayAdd:

#include <Array.au3>
...
Global $aUsername_Array[1], $aPassword_Array[1] ; you need this include file for the _Array functions
...
$username=GUICtrlRead($chooseusername) ; get the variable
_ArrayAdd($aUsername_Array, $username) ; add it to the array
$password=GUICtrlRead($choosepassword)
_ArrayAdd($aPassword_Array, $password)
...
_FileWriteFromArray ($1,$aUsername_Array) ; now you can save the array - and later read it back with _FileReadTo Array
_FileWriteFromArray ($2,$aPassword_Array)

You can use the _ArrayDisplay function to look at your arrays after you add a new element to check it has gone in correctly.

Play with this code and look at the Help file to understand how to use arrays. Arrays are not difficult, but you need to make sure you are happy with how to address the elements within them - more than one program has fallen over becasue the wrong element was extracted from an array (including many of mine!)

Keep up the good work.

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
TheOnlyOne

okay i read about the arrays alot i dident know (thanks for showing where :) ) but this dident really fix my new problem ...

While 1
                Switch GUIGetMsg()
                    Case $loginButton1
                        $username2=GUICtrlRead($yourusername)
                        _ArrayAdd ($ausername_Ins_array,$username2)
                        $password2=GUICtrlRead($yourpassword)
                        _arrayadd ($apassword_Ins_array,$password2)
                        
                        
                    $3=_FileReadToArray ("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$ausername_Ins_array)
                    $4=_FileReadToArray ("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$apassword_Ins_array)
                if $3= not  $ausername_array then 
                if $4= not  $aPassword_array then

            msgbox (0,"login is wrong pls try agian","")
        EndIf
        EndIf
                if $3 = $ausername_array then 
                    if $4 = $aPassword_array then
                msgbox (0,"loading","pls w8 a sec")

as you can see i tryed to make new variables but dont know about that is right so i tryed to take them i allready used but dident work ether ? and now its allways wrigtig my login is wrong:S? im sorry you nearly need to explain me step to step but i cant figure out what to do know :S?

Share this post


Link to post
Share on other sites
BrettF

okay i read about the arrays alot i dident know (thanks for showing where :) ) but this dident really fix my new problem ...

While 1
                Switch GUIGetMsg()
                    Case $loginButton1
                        $username2=GUICtrlRead($yourusername)
                        _ArrayAdd ($ausername_Ins_array,$username2)
                        $password2=GUICtrlRead($yourpassword)
                        _arrayadd ($apassword_Ins_array,$password2)
                        
                        
                    $3=_FileReadToArray ("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$ausername_Ins_array)
                    $4=_FileReadToArray ("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$apassword_Ins_array)
                if $3= not  $ausername_array then 
                if $4= not  $aPassword_array then

            msgbox (0,"login is wrong pls try agian","")
        EndIf
        EndIf
                if $3 = $ausername_array then 
                    if $4 = $aPassword_array then
                msgbox (0,"loading","pls w8 a sec")

as you can see i tryed to make new variables but dont know about that is right so i tryed to take them i allready used but dident work ether ? and now its allways wrigtig my login is wrong:S? im sorry you nearly need to explain me step to step but i cant figure out what to do know :S?

I think you mean to try understand how arrays work correct? I'm not sure what your doing exactly as I didn't bother to read everything, but you answer may lie with _ArraySearch?

melba.. TheOnlyOne..

Did u guys even read my suggestion?? This is a forum, where we discuss.. u guys can't just ignore suggestions.. it's very rude.. n frankly I believe my idea is much better than what u guys are doing..

You may think, but others may think differently. It is possible that your post was missed... It happens?

And you're being rude by whining that no one listened to you. They have a solution going, and I seems to be going well, so just let it be.

Brett

Share this post


Link to post
Share on other sites
Manjish

alright.. i am sorry for whinning.. lol.. no hard feelings..

Cheers..


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites
Inverted

@ Manjish

Haha, happened sometimes to me too. You should understand that there are many solutions to a problem, even if some are "better" than others.

Edited by Inverted

Share this post


Link to post
Share on other sites
Manjish

@inverted..

Understand perfectly, what u mean :)


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites
Melba23

TheOnlyOne,

I see you have problems with the concept of arrays. Think of them as a quick way to create lots of similar variables. A short example:

Dim $aExample_Array[3] creates an array with 3 elements. These are $aExample_Array[0], $aExample_Array[1] and $aExample_Array[2] (Note that the elements are numbered from 0, not 1). You can then store numbers, strings or anything else you want in these elements. You define the element you want by using the number in the [] - this is known as the index. So if we wanted to put the parts of your UserName in this array, we would write:

$aExample_Array[0] = "The"

$aExample_Array[1] = "Only"

$aExample_Array[2] = "One"

One of the great advantages of an array is that you can move through the elements using For...Next loops. So to read back the parts of your username we can do this:

For $i = 0 To 2

ConsoleWrite($aExample_Array[$i] & @CRLF)

Next

The advantage of this ability to use loops becomes obvious when you think of much larger arrays. I use an array with about 5500 elements to list mp3 tracks - can you imagine having to write 5500 different variables? How much easier to use an array with 5500 elements.

; ------------------------------------------------

So in your script we need to add the following at the beginning (after the include files):

; Declare the arrays
Global $aUsername_Array[1] = [0], $aPassword_Array[1] = [0]

This lets AutoIt know that these variables are arrays. At the moment they have only 1 element (becasue we have not yet added any usernames or passwords) which we have set to 0. Setting the first element of an array as the count of the other elements is quite common - AutoIt does it in many cases. As we have no other elements yet, we set the count to 0.

; ------------------------------------------------

Now let us add a usename to the array. We do this in the loop for the "Register" button:

While 1
    Switch GUIGetMsg()
        Case $backButton 
            GUISetState(@SW_SHOW,$Form1_1)
            GUISetState(@SW_hide,$Form3)
            ExitLoop
        Case $registerButton1
    ; Here we add the new username and password to the files where they are stored
        ; Read the files into the arrays
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$aUsername_Array)
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$aPassword_Array)
        ; Get the variables
            $username=GUICtrlRead($chooseusername)
            $password=GUICtrlRead($choosepassword)
        ; Add them to the arrays
            _ArrayAdd($aUsername_Array, $username)  
            _ArrayAdd($aPassword_Array, $password)
        ; Increase the count of the elements
            $aUsername_Array[0] += 1                    
            $aPassword_Array[0] += 1
        ; Write the files again
            _FileWriteFromArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$aUsername_Array, 1)
             _FileWriteFromArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$aPassword_Array, 1)
        ; Return automatically
            GUISetState(@SW_SHOW,$Form1_1)
            GUISetState(@SW_hide,$Form3)
            ExitLoop
                EndSwitch
WEnd

What is happening here? First we use _FileReadToArray to read in the files containing the already existing usernames and passwords into the arrays we declared earlier. If the files exist, AutoIt fills the arrays for us - if not then our arrays stay empty.

Then we get the user to give us a username and password - we have done that before.

Next, these are added to the arrays using a function _ArrayAdd from the Array.au3 include file. Because we are adding these values, we next increase the count in the first element.

Then we write the files to disk with _FileWriteFromArray.

; --------------------------------------------

The code for checking the username and password in the loop for the Login button is very similar:

While 1
    Switch GUIGetMsg()
        Case $loginButton1
    ; Here we search for the username and password in the files where they are stored
        ; Read the files into the arrays
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$aUsername_Array)
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$aPassword_Array)
        ; Get the variables
            $username=GUICtrlRead($enterusername)
            $password=GUICtrlRead($enterpassword)
        ; Now look for the username in the array
            $index = _ArraySearch($aUsername_Array, $username)
        ; If username is not found
            If $index = -1 Then
            ; Say it was wrong
                MsgBox(0,"Error", "Username does not exist")
            ; Go back
                GUISetState(@SW_SHOW,$Form1_1)
                GUISetState(@SW_hide,$Form2)
                ExitLoop
            EndIf
        ; username was found, so compare password to matching index in password array
            If $password <> $aPassword_Array[$index] Then
            ; Say if it was wrong
                MsgBox(0,"Error", "Incorrect password")
            ; Go back
                GUISetState(@SW_SHOW,$Form1_1)
                GUISetState(@SW_hide,$Form2)
                ExitLoop
            EndIf
        ; If we are here, everything is good!
            GUICtrlSetData($loginButton1, "Please Login")
                        
        ; here you can put your code for a successful login
        ; For the moment we just say so!
            MsgBox(0,"Success", "Please Login")
                        
            GUISetState(@SW_SHOW,$Form1_1)
            GUISetState(@SW_hide,$Form2)
            ExitLoop
    EndSwitch
WEnd

Here we read the two files we saved before and get AutoIt to put them in the arrays for us. The user puts in a username and password.

We now use the _ArraySearch function to look for the username in $aUserName_Array. If it finds the username it returns the index of the username - that is the number in [] which defines that element of the array. For example, if we were looking for "Only" in our example at the beginning, the index would be 1 because $aExample_Array[1] = "Only". If AutoIt does not find the username, it returns -1. We check if this happens and if it does, we create a MsgBox to say so.

We do a similar thing for the password. But if all is well we can log in!

Of course we do not have to rewrite the username and password files here because we have not changed them, only read them.

; --------------------------------------------

One final thing. If you want to store the username and password files in a new folder, you have to create it first! So add the following at the beginning of your script:

; Create the \users folder if it does not exist
If Not FileExists("C:\Documents and Settings\lo\Skrivebord\game menu\users") Then DirCreate("C:\Documents and Settings\lo\Skrivebord\game menu\users")

Ask if you do not understand something.

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
TheOnlyOne

ah i dident really know it was that way you were useing arrays :) thanks

but agian one problem it says the username dont exists when im trying to log in after register a new user :S cant really understand why here is my script so you can se what i did wrong for i cant see it (Tryed to set in @error in the msgbox under where it gonna check the username and its error 6 = "$vValue was not found in array")

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
#include <Array.au3>
If Not FileExists("C:\Documents and Settings\lo\Skrivebord\game menu\users") Then DirCreate("C:\Documents and Settings\lo\Skrivebord\game menu\users")
Global $aUsername_Array[1] = [0], $aPassword_Array[1] = [0]
$2=fileopen("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",1)
$1=fileopen("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",1)
global $avArray[1]
#Region ### START Koda GUI section ### Form=c:\documents and settings\lo\skrivebord\form2.kxf
$Form1_1 = GUICreate("Form1", 628, 299, 193, 125)
    GUISetBkColor(0xA6CAF0)
$register = GUICtrlCreateButton("Register", 24, 24, 186, 71, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon.bmp", 0)
$login = GUICtrlCreateButton("LogIn", 24, 112, 184, 77, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login!.bmp", 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $press= GUIGetMsg()
    Switch $press
        Case $GUI_EVENT_CLOSE
            Exit
       

        Case $register
            GUISetState(@SW_hide,$Form1_1)
            $Form3 = GUICreate("register", 308, 220, 178, 116,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
            $chooseusername= GUICtrlCreateInput("", 32, 56, 241, 21)
            $Label1 = GUICtrlCreateLabel("Choose your username.", 32, 32, 163, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $Label2 = GUICtrlCreateLabel("Choose your password.", 33, 111, 162, 16)
                GUICtrlSetFont(-1, 9, 800, 0, "Gulim")
            $choosepassword=GUICtrlCreateInput("", 30, 131, 241, 21)
            $registerButton1 = GUICtrlCreateButton("Register", 40, 168, 67, 20, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\register-icon-small.bmp", 0)
            $backButton = GUICtrlCreateButton("Back", 176, 168, 65, 22, $BS_BITMAP, $WS_EX_CLIENTEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\back.bmp", 0)
            GUISetState(@SW_SHOW)
            
            While 1
    Switch GUIGetMsg()
        Case $backButton 
            GUISetState(@SW_SHOW,$Form1_1)
            GUISetState(@SW_hide,$Form3)
            ExitLoop
        Case $registerButton1
  ; Here we add the new username and password to the files where they are stored
      ; Read the files into the arrays
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$aUsername_Array)
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$aPassword_Array)
      ; Get the variables
            $username=GUICtrlRead($chooseusername)
            $password=GUICtrlRead($choosepassword)
      ; Add them to the arrays
            _ArrayAdd($aUsername_Array, $username)  
            _ArrayAdd($aPassword_Array, $password)
      ; Increase the count of the elements
            $aUsername_Array[0] += 1                    
            $aPassword_Array[0] += 1
      ; Write the files again
            _FileWriteFromArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$aUsername_Array, 1)
             _FileWriteFromArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$aPassword_Array, 1)
      ; Return automatically
            GUISetState(@SW_SHOW,$Form1_1)
            GUISetState(@SW_hide,$Form3)
            ExitLoop
                EndSwitch
WEnd
            Case $login
            $Form2 = GUICreate("Login", 360, 329, 193, 125,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))
                GUISetBkColor(0xA6CAF0)
                $enterpassword=GUICtrlCreateInput("", 24, 40, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label1 = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
                $enterusername=GUICtrlCreateInput("", 24, 96, 265, 19)
                GUICtrlSetFont(-1, 8, 800, 2, "Gulim")
                GUICtrlSetColor(-1, 0x800000)
                GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT)
            $Label2 = GUICtrlCreateLabel("Password", 24, 72, 82, 17)
            $loginButton1 = GUICtrlCreateButton("(Not allowed)", 24, 136, 158, 37, BitOR($BS_BITMAP,$WS_BORDER), $WS_EX_STATICEDGE)
                GUICtrlSetImage(-1, "C:\Documents and Settings\lo\Skrivebord\game menu\Login2.bmp", 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###
            
           While 1
    Switch GUIGetMsg()
        Case $loginButton1
  ; Here we search for the username and password in the files where they are stored
      ; Read the files into the arrays
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\username.txt",$aUsername_Array)
            _FileReadToArray("C:\Documents and Settings\lo\Skrivebord\game menu\users\password.txt",$aPassword_Array)
      ; Get the variables
            $username=GUICtrlRead($enterusername)
            $password=GUICtrlRead($enterpassword)
      ; Now look for the username in the array
            $index = _ArraySearch($aUsername_Array, $username)
      ; If username is not found
            If $index = -1 Then
          ; Say it was wrong
                MsgBox(0,"error", "Username does not exist")
          ; Go back
                GUISetState(@SW_SHOW,$Form1_1)
                GUISetState(@SW_hide,$Form2)
                ExitLoop
            EndIf
      ; username was found, so compare password to matching index in password array
            If $password <> $aPassword_Array[$index] Then
          ; Say if it was wrong
                MsgBox(0,"Error", "Incorrect password")
          ; Go back
                GUISetState(@SW_SHOW,$Form1_1)
                GUISetState(@SW_hide,$Form2)
                ExitLoop
            EndIf
      ; If we are here, everything is good!
            GUICtrlSetData($loginButton1, "Please Login")
                        
      ; here you can put your code for a successful login
      ; For the moment we just say so!
            MsgBox(0,"Success", "Please Login")
                        
            GUISetState(@SW_SHOW,$Form1_1)
            GUISetState(@SW_hide,$Form2)
            ExitLoop
    EndSwitch
WEnd
                        ExitLoop
                EndSwitch
            WEnd


fileclose($1)
fileclose($2)
Edited by TheOnlyOne

Share this post


Link to post
Share on other sites
Melba23

TheOnlyOne,

Try getting $enterusername and $enterpassword from the correct inputs - you have them reversed at the moment!

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
TheOnlyOne

i really tried too se what you ment for i can really not see were you see its a wrong input

$enterpassword=GUICtrlCreateInput("", 24, 40, 265, 19)
_________________________________________________
$enterusername=GUICtrlCreateInput("", 24, 96, 265, 19)

where is im setting it to the wrong input? :S

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.