Jump to content

Recommended Posts

Posted

I have a problem here and I hope someone can help.

I have a GUI that when used will activate a program and enter then program. I am trying to make the GUI close after the other one opens. I have tryed alot of option, but to no success. When the program opens and then I try and close it by clicking the "x" the GUI just sits there and the only way of closing it is using a ctrl alt del close of the GUI. The code is as follows:

; Lines 16 - 23 are setting up the GUI.
$Form1 = GUICreate("XLCapital Visual SourceSafe Login", 320, 165, 192, 125)
$InputUserName = GUICtrlCreateInput("",65, 27, 169, 21)
$InputPassword = GUICtrlCreateInput("", 65, 80, 169, 21, $ES_PASSWORD)
$BtnClose = GUICtrlCreateButton("Exit", 100,110)
$BtnNext = GUICtrlCreateButton("Next",140,110)
GUICtrlCreateLabel ("Please Enter your Password", 80, 59 )
GUICtrlCreateLabel ("Please Enter your Username", 80, 6)
; GUISetState makes the form show on the screen
GUISetState(@SW_SHOW)



; the GUICtrlSetState function disables the $InputFolder so the user can not manually enter data in the input box.  
While 1
    ; $msg is used to react with what actions are happening on the GUI.  
    $msg = GuiGetMsg()
    Select
    ; Line 36 is the "X" button coding.  
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    
        Case $msg = $BtnNext
        
    ; The following lines are tied into the OK button.
    ; Lines 55 - 62 read the input boxes and then checks to see if there is a null value in them.
    ; Then lines 63 - 80 gives errors if there is a null value or an invalid char in the input box.
            $ReadUserName = GUICtrlRead($InputUserName)
            $NullCheckUserName = StringReplace($ReadUserName, "|", @CRLF)
            $ReadPassword = GUICtrlRead($InputPassword)
            $NullCheckPassword = Stringreplace($ReadPassword, "|",@CRLF)
        
            If $NullCheckUserName = "" Then 
                msgbox(16,"Error","Please Enter in an UserName")
                Controlfocus ("","",$InputUserName)
            ElseIf $NullCheckPassword = "" Then
                msgbox(16,"Error","Please Enter in a Password")
                Controlfocus ("","",$InputPassword)
            Else
                Run("C:\Program Files\Microsoft Visual Studio\VSS\win32\SSEXP.EXE")
                WinWaitActive("Visual SourceSafe Login")
                ;Enter The Username in the ControlID 8003 input/txt box
                ControlSetText("Visual SourceSafe Login", "", 8003, $ReadUserName)
                ;Enter the Password in the 8006 input/txt box
                ControlSetText("Visual SourceSafe Login", "", 8006, $ReadPassword) 
                ;Browse button is 8263
                ControlClick("Visual SourceSafe Login", "", 8263)
                
            EndIf
    
            
        
    EndSelect

WEnd
Posted

maybe

Else
                Run("C:\Program Files\Microsoft Visual Studio\VSS\win32\SSEXP.EXE")
                WinWaitActive("Visual SourceSafe Login")    
                 GUIDelete($Form1)

8)

NEWHeader1.png

Posted

Perhaps this may work better. Using WinWait() instead of WinWaitActive(), as Control*() functions do not need an active window. Also just hiding the Gui window to see the ControlSetText() event happen.

; Lines 16 - 23 are setting up the GUI.
$Form1 = GUICreate("XLCapital Visual SourceSafe Login", 320, 165, 192, 125)
$InputUserName = GUICtrlCreateInput("",65, 27, 169, 21)
$InputPassword = GUICtrlCreateInput("", 65, 80, 169, 21, $ES_PASSWORD)
$BtnClose = GUICtrlCreateButton("Exit", 100,110)
$BtnNext = GUICtrlCreateButton("Next",140,110)
GUICtrlCreateLabel ("Please Enter your Password", 80, 59 )
GUICtrlCreateLabel ("Please Enter your Username", 80, 6)
; GUISetState makes the form show on the screen
GUISetState(@SW_SHOW)



; the GUICtrlSetState function disables the $InputFolder so the user can not manually enter data in the input box.  
While 1
    ; $msg is used to react with what actions are happening on the GUI.  
    $msg = GuiGetMsg()
    Select
    ; Line 36 is the "X" button coding.  
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $BtnClose; <----- Added this in
            Exit
            
        Case $msg = $BtnNext
        
    ; The following lines are tied into the OK button.
    ; Lines 55 - 62 read the input boxes and then checks to see if there is a null value in them.
    ; Then lines 63 - 80 gives errors if there is a null value or an invalid char in the input box.
            $ReadUserName = GUICtrlRead($InputUserName)
            $NullCheckUserName = StringReplace($ReadUserName, "|", @CRLF)
            $ReadPassword = GUICtrlRead($InputPassword)
            $NullCheckPassword = Stringreplace($ReadPassword, "|",@CRLF)
        
            If $NullCheckUserName = "" Then 
                msgbox(16,"Error","Please Enter in an UserName")
                Controlfocus ("","",$InputUserName)
            ElseIf $NullCheckPassword = "" Then
                msgbox(16,"Error","Please Enter in a Password")
                Controlfocus ("","",$InputPassword)
            Else
                GUISetState(@SW_HIDE)
                Run(@ProgramFilesDir & "\Microsoft Visual Studio\VSS\win32\SSEXP.EXE")
                If WinWait("Visual SourceSafe Login", "", 60) Then
                    ;Enter The Username in the ControlID 8003 input/txt box
                    ControlSetText("Visual SourceSafe Login", "", 8003, $ReadUserName)
                    ;Enter the Password in the 8006 input/txt box
                    ControlSetText("Visual SourceSafe Login", "", 8006, $ReadPassword) 
                    ;Browse button is 8263
                    ControlClick("Visual SourceSafe Login", "", 8263)
                EndIf
                GUISetState(@SW_SHOW)
            EndIf
    
            
        
    EndSelect

WEnd
Posted

I had a similar question, but i figured it out myself. Instead of closing the GUI, i just set it to @SW_HIDE after i click my main button

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...