Jump to content

Recommended Posts

Posted (edited)
While Not _Login()
    _Login()
WEnd

_Initial_Check()

GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON, $BTN_EXIT
            _GUIDisable($GUI_MAIN, 0, 30)
            _Close_Application()
    EndSwitch
WEnd

; #FUNCTION# ====================================================================================================================
; Name ..........: _Password_Check
; Description ...: To check against the input with the password file
; ===============================================================================================================================
Func _Password_Check()
    Local $IN_PASSWORD = _Metro_InputBox("Please Enter Your Password:" , 11, "", True, True)

    If @error Then
        Return SetError(1, 0, "")
    ElseIf $PASSWORD <> $IN_PASSWORD Then
        Return SetError(2, 0, "Access Denied!")
    Else
        Return True
    EndIf
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _Login
; Description ...: Login
; ===============================================================================================================================
Func _Login()
    Local $FLAG_LOGIN = _Password_Check()

    If @error = 1 Then
        _Close_Application()
    ElseIf @error = 2 Then
        _Metro_MsgBox(0, "", $FLAG_LOGIN)
        Return False
    Else
        _Metro_MsgBox(0, "", "Access Granted!")
        Return True
    EndIf
EndFunc

When the application start, it will prompt for password for login.

I entered several wrong password, it shows "Access Denied!" and re-prompt for password for login.
Then I entered the correct one, it shows "Access Granted!" but it still re-prompt for password for login.

Any idea what's wrong? Thanks

Edited by gahhon
Posted

Why open a new thread?

You're calling _Login function twice so not really sure what you expect to happen, @Bilgus post in the other thread or the following should work as we're only calling the function once.

Do
    Sleep(1000)
Until _Login()
Posted
23 hours ago, Subz said:

Why open a new thread?

You're calling _Login function twice so not really sure what you expect to happen, @Bilgus post in the other thread or the following should work as we're only calling the function once.

Do
    Sleep(1000)
Until _Login()

Sorry for open duplicate thread.

So what are you trying to mean is the While condition called the function, when the function return False then call the function.
When the 2nd time function called return True, it goes back the While Loop and call the function to check the condition. Am I right?

 

Posted

While Not _Login() ;~ Login1: If this fires and returns false, it will continue the loop, otherwise it will exit the loop correctly.
     _Login()              ;~ Login2: If this fires and returns true or false, you haven't told it to do anything, so it will restart the loop
Wend

 

Posted
13 hours ago, Subz said:

While Not _Login() ;~ Login1: If this fires and returns false, it will continue the loop, otherwise it will exit the loop correctly.
     _Login()              ;~ Login2: If this fires and returns true or false, you haven't told it to do anything, so it will restart the loop
Wend

 

Understood. Thanks

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
×
×
  • Create New...