gahhon Posted January 17, 2019 Posted January 17, 2019 (edited) expandcollapse popupWhile 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 January 17, 2019 by gahhon
Subz Posted January 17, 2019 Posted January 17, 2019 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()
gahhon Posted January 18, 2019 Author Posted January 18, 2019 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?
Subz Posted January 18, 2019 Posted January 18, 2019 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
gahhon Posted January 19, 2019 Author Posted January 19, 2019 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now