Jump to content

Username Password Script


 Share

Recommended Posts

I found the following script posted, but it errors out with

If Not $INISECTION[0][0]>=1 Then Return 0

If Not $INISECTION^Error

Error: Subscript used with non-Array variable

can anyone post a fix to this? This is a great script and work well for me.

Thanks

here is the script:

#include <guiconstants.au3>

VERIFYUSER()

Func VERIFYUSER()

Local $FILEPATHTOINI = @DesktopDir & 'Data\pass.INI'; CHANGE THIS TO THE PATH OF YOUR INI

$VERIFYGUI = GUICreate('Username - Password Validation', 210, 145)

GUICtrlCreateLabel('USERNAME', 10, 10)

$USERNAME = GUICtrlCreateInput('', 10, 30, 190, 20)

GUICtrlCreateLabel('PASSWORD', 10, 60)

$PASSWORD = GUICtrlCreateInput('', 10, 80, 190, 20, $ES_PASSWORD)

$SUBMIT = GUICtrlCreateButton('SUBMIT', 75, 110, 50, 30)

GUISetState()

While 1

$MSG = GUIGetMsg()

Select

Case $MSG = $GUI_EVENT_CLOSE

Exit

Case $MSG = $SUBMIT

$READUSERNAME = GUICtrlRead($USERNAME)

$READPASSWORD = GUICtrlRead($PASSWORD)

If $READUSERNAME <> '' And $READPASSWORD <> '' Then

$CHECKUP = CHECKUSERNAMEPASSWORD($READUSERNAME, $READPASSWORD, $FILEPATHTOINI)

If $CHECKUP == 0 Then

If MsgBox(68, 'INFO:', 'WE DO NOT SEEM TO HAVE YOUR USERNAME AND PASSWORD ON FILE?' _

& @CR & 'WOULD YOU LIKE TO USE THIS INFO YOU HAVE PROVIDED TO CREATE ONE?') == 6 Then

CREATEUSERNAMEPASSWORD($READUSERNAME, $READPASSWORD, $FILEPATHTOINI)

EndIf

ElseIf $CHECKUP == 1 Then

MsgBox(64, 'SUCCESS', 'YOU HAVE BEEN LOGGED IN')

ExitLoop

EndIf

Else

MsgBox(64, 'ERROR', 'YOU DID NOT FILL IN EITHER THE USERNAME OR PASSWORD.')

EndIf

EndSelect

WEnd

GUIDelete($VERIFYGUI)

EndFunc

Func CHECKUSERNAMEPASSWORD($v_USERNAME, $v_PASSWORD, $h_FILEPATH)

Local $INISECTION = IniReadSection($h_FILEPATH, 'UsernamePassword')

Local $FOUND = 0

If Not $INISECTION[0][0] >= 1 Then Return 0

For $iINIREAD = 1 To $INISECTION[0][0]

If StringInStr($INISECTION[$iINIREAD][0], $v_USERNAME) And StringInStr($INISECTION[$iINIREAD][1], $v_PASSWORD) Then

$FOUND = 1

ExitLoop

EndIf

Next

If $FOUND = 1 Then Return 1

EndFunc

Func CREATEUSERNAMEPASSWORD($v_USERNAME, $v_PASSWORD, $h_FILEPATH)

IniWrite($h_FILEPATH, 'UsernamePassword', $v_USERNAME, $v_PASSWORD)

EndFunc

Link to comment
Share on other sites

It sounds like you don't have the ini file created yet.

I do have it created in folder called Data on my desktop, and this is where the script is also but not sure I am entering it correctly in the @DesktopDir

Link to comment
Share on other sites

I do have it created in folder called Data on my desktop, and this is where the script is also but not sure I am entering it correctly in the @DesktopDir

Add this to the top of your function:

Func VERIFYUSER()
Local $FILEPATHTOINI = @DesktopDir & 'Data\pass.INI'; CHANGE THIS TO THE PATH OF YOUR INI
If Not FileExist($FILEPATHTOINI) Then 
     MsgBox(16, "Error", "File not found: " & $FILEPATHTOINI)
     Return 0 ; (I'm assuming 0=fail for this function)
EndIf
.
.
.
EndFunc

If it fails there it will tell you where it was looking. :think:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...