Sign in to follow this  
Followers 0
saldous

GUI doesn't stay on screen

3 posts in this topic

#1 ·  Posted (edited)

I've built a GUI using Koda, this is a great tool by the way. the GUI captures some fields, email, name, password etc.. and then does a check on the password length. I had all this working earlier today, until I copied and pasted something, it didn't work, I tried to go back to what I had before and SciTE4 auto saved over the top of it. So now I'm trying to fix it, the problem is that now when I run my script the GUI gets displayed for about 1/2 a second and then disapears again before I can type anything in the input boxes. Is someone able to take a quick scan over my code to see what I've done in error? I've looked at this for 2 hours now and am going cross-eyed trying to find the problem!

Thanks

#include <GUIConstants.au3>

#Region ### START Koda GUI section ###
$Screen1 = GUICreate("App Installer", 320, 241, -1, -1)
GUISetIcon("Agent.ico")
TraySetIcon("Agent.ico")
Local $aCID, $iY = 0, $sRead
$GroupBox1 = GUICtrlCreateGroup("", 8, 1, 305, 193)
$FNameInput = GUICtrlCreateInput("", 120, 16, 185, 21)
$SNameInput = GUICtrlCreateInput("", 120, 40, 185, 21)
$EmailInput = GUICtrlCreateInput("", 120, 80, 185, 21)
$PasswdInput = GUICtrlCreateInput("", 120, 120, 185, 21, $ES_PASSWORD)
$Passwd2Input = GUICtrlCreateInput("", 120, 152, 185, 21, $ES_PASSWORD)
$FName = GUICtrlCreateLabel("First Name", 16, 19, 54, 17)
$SName = GUICtrlCreateLabel("Surname", 16, 46, 46, 17)
$Email = GUICtrlCreateLabel("Email Address", 16, 84, 70, 17)
$Passwd = GUICtrlCreateLabel("Password", 16, 124, 50, 17)
$Passwd2 = GUICtrlCreateLabel("Confirm Password", 16, 156, 88, 17)

; Set Max and Min character limits for Password entry
GUICtrlSetLimit($PasswdInput, 20, 6); Max to 20, Min 6 characters
GUICtrlSetLimit($Passwd2Input, 20, 6); Max to 20, Min 6 characters

; Add the Next and Cancel buttons to the GUI
GUICtrlCreateGroup("", -99, -99, 1, 1)
$NextButton = GUICtrlCreateButton("&Next >", 237, 204, 75, 25, 0)
$CancelButton = GUICtrlCreateButton("&Cancel", 149, 204, 75, 25, 0)
$Pic1 = GUICtrlCreatePic("Logo.jpg", 12, 202, 116, 28, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; Start While loop to validate password length
$loop = 1
While $loop = 1
    Switch GUIGetMsg()
        
    Case $CancelButton
        MsgBox(0, "", "Installation Cancelled")
        Exit
        
    Case $GUI_EVENT_CLOSE
        MsgBox(0, "", "Installation Cancelled")
        Exit
        
    Case $NextButton
    $sRead = GUICtrlRead($PasswdInput)
    
    Case StringLen($sRead) <= 15 And StringLen($sRead) >= 6 Then
        Return $sRead
        $loop = 0
        
    Case StringLen($sRead) > 15 Then
        MsgBox(262144 + 16, 'Password Length Error', 'Your password must be less than 15 characters.')
        
    Case StringLen($sRead) < 6 Then
        MsgBox(262144 + 16, 'Password Length Error', 'Your password must be a minimum of 6 characters.')
        
    EndSwitch

WEnd
Edited by saldous

Share this post


Link to post
Share on other sites



Hmm, some of that looks familiar :whistle: ...

Anyway, your case statements are messed up and they error.

#include <GUIConstants.au3>
#Region ### START Koda GUI section ###
$Screen1 = GUICreate("App Installer", 320, 241, -1, -1)
GUISetIcon("Agent.ico")
TraySetIcon("Agent.ico")
Local $aCID, $iY = 0, $sRead
$GroupBox1 = GUICtrlCreateGroup("", 8, 1, 305, 193)
$FNameInput = GUICtrlCreateInput("", 120, 16, 185, 21)
$SNameInput = GUICtrlCreateInput("", 120, 40, 185, 21)
$EmailInput = GUICtrlCreateInput("", 120, 80, 185, 21)
$PasswdInput = GUICtrlCreateInput("", 120, 120, 185, 21, $ES_PASSWORD)
$Passwd2Input = GUICtrlCreateInput("", 120, 152, 185, 21, $ES_PASSWORD)
$FName = GUICtrlCreateLabel("First Name", 16, 19, 54, 17)
$SName = GUICtrlCreateLabel("Surname", 16, 46, 46, 17)
$Email = GUICtrlCreateLabel("Email Address", 16, 84, 70, 17)
$Passwd = GUICtrlCreateLabel("Password", 16, 124, 50, 17)
$Passwd2 = GUICtrlCreateLabel("Confirm Password", 16, 156, 88, 17)
; Set Max and Min character limits for Password entry
GUICtrlSetLimit($PasswdInput, 20, 6); Max to 20, Min 6 characters
GUICtrlSetLimit($Passwd2Input, 20, 6); Max to 20, Min 6 characters
; Add the Next and Cancel buttons to the GUI
GUICtrlCreateGroup("", -99, -99, 1, 1)
$NextButton = GUICtrlCreateButton("&Next >", 237, 204, 75, 25, 0)
$CancelButton = GUICtrlCreateButton("&Cancel", 149, 204, 75, 25, 0)
$Pic1 = GUICtrlCreatePic("Logo.jpg", 12, 202, 116, 28, BitOR($SS_NOTIFY, $WS_GROUP))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
; Start While loop to validate password length
$loop = 1
While $loop = 1
    Switch GUIGetMsg()
        Case $CancelButton
            MsgBox(0, "", "Installation Cancelled")
            Exit
        Case $GUI_EVENT_CLOSE
            MsgBox(0, "", "Installation Cancelled")
            Exit
        Case $NextButton
            $sRead = GUICtrlRead($PasswdInput)
            If StringLen($sRead) <= 15 And StringLen($sRead) >= 6 Then ExitLoop
            If StringLen($sRead) > 15 Then 
                MsgBox(262144 + 16, 'Password Length Error', 'Your password must be less than 15 characters.')
            ElseIf StringLen($sRead) < 6 Then
                MsgBox(262144 + 16, 'Password Length Error', 'Your password must be a minimum of 6 characters.')
            EndIf
    EndSwitch
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

SmOke N you've saved me once again, your too kind. :whistle:

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  
Followers 0