mrmacro

action when button pressed in a while statement

3 posts in this topic

#1 ·  Posted (edited)

I am reasonably new to AutoIt but have been working on a script for a few months  searching Google and many other forums for code that helps me complete my task

I have RTFM but can't seem to find, or if I have then I not made sense of this ,so if someone can look at the below code and see where I am going wrong

I have used the Koda to generate the GUI and that seems ok its only the case statement below that I seem to have problems with

the form is a Username, Password, Domain and PVN 

I can get it to exit if the $Btn_Cancel is pressed but what I can't get it to do is once the $Btn_Submit is pressed is to continue to the MsgBox and continue the script

I have implemented all of this , and it works using separate input boxes but I wanted only one prompt and enter all the details , rather than multiple input popups keep coming up and asking for input

The $Inp_myUsername , $Inp_myPassword , $Inp_myPvn have all been declared as Global in the GUI

this is just where I believe the problem to be

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Btn_Cancel
            MsgBox(0, "Operation has been cancelled", "The Script will now quit.", 3)
            Exit
        Case $Btn_Submit
            $Inp_myUsername = GUICtrlRead($Inp_myUsername)
            ;MsgBox(0, "User", $Inp_myUsername)
            $Inp_myPassword = GUICtrlRead($Inp_myPassword)
            $Inp_myPvn = GUICtrlRead($Inp_myPvn)
            If ($Inp_myPassword = "Inp_Password" And $Inp_myPvn = "8_Digits") Then
                MsgBox(0, "Invalid Details", "Invalid Password & Invalid Pvn")
                Exit
            EndIf
            If ($Inp_myPassword == "Inp_Password" And $Inp_myPvn <> "8_Digits") Then
                MsgBox(0, "Password Invalid", "Invalid Password & Possible Valid Pvn")
                Exit
            EndIf
            If ($Inp_myPassword <> "Inp_Password" And $Inp_myPvn = "8_Digits") Then
                MsgBox(0, "Pvn Invalid", "Possible Valid Password & Invalid Pvn")
                Exit
            EndIf
            If ($Inp_myPassword <> "Inp_Password" And $Inp_myPvn <> "8_Digits") Then
                ;MsgBox(0, "Pvn Invalid", "Possible Valid Password & Invalid Pvn")
                GUIDelete()
            EndIf
            
    EndSwitch
WEnd

;its not getting to this part it just seems to hang

 

#Region Login MessageBox ---
MsgBox(0, "Wait", "Before Continuing further Please Now Open ' Login'" & @CRLF & @CRLF & "Down by the clock Click on the arrow to show any hidden icons then right click on to the Login icon and select connect" & @CRLF & "Be sure to select the Password Box")
#EndRegion Login MessageBox ---

 

;Other code below that I believe is not needed to show this example

 

Edited by mrmacro

Share this post


Link to post
Share on other sites



#3 ·  Posted

17 minutes ago, Jos said:

Add an ExitLoop underneath the Guidelete() to exit the While loop. ;)

Jos

perfect just another fresh pair of eyes and its all fixed many thanks , seen many posts about RTFM and didn't want to get that reply like others as I have been looking and editing and changing code without any luck and now had to post a message and just exitloop fixed this thanks

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