weevil

GUI won't close properly

4 posts in this topic

Hi All,

I am new to the world of GUI AutoIt, but I know my way around the program.

I am trying to automate the logging in of a piece of software, and there comes a point during the script where I need to get user input to continue.  I've created a rudimentary text box and OK button to facilitate this, but when I do it won't close the GUI gracefully and continue running the script, it just halts and doesn't carry on.

 

#include <GUIConstants.au3>
global $address = "testaddress"
global $port = "1111"
global $logonscript = ""
global $script = ""

run("C:\Program Files (x86)\Crystal Point\OutsideView\outside32.exe")
WinWait("OutsideView - Untitled Workspace")
sleep(500)
WinActivate("OutsideView - Untitled Workspace")
Sleep(2000)
Send("^n")
Login()
Sleep(2000)
LogonScript()
Sleep(2000)
Login2()

Func Login()
   Local $handle = WinWait("Session Settings")
      WinActivate($handle)
      ToolTip($handle)
      ControlClick($handle, "", "SysTreeView32")                            ;focus into left hand menu bar
      Send("{DOWN 2}")                                                      ;navigate to IO
      sleep(500)
      ControlGetFocus($handle, "")                                          ;confirm focus
      ControlSend($handle, "", "ComboBox1", "^a {DEL}")                     ;remove current address in box.
      ControlSend($handle, "", "ComboBox1" , $address & " " & $port)        ;input address and port into box
      ControlClick($handle, "", "Button4")                                  ;click "encrypt data stream using SSL"
      ControlClick($handle, "", "Button5")                                  ;click "invoke service/logon script"
      ControlClick($handle, "", "Button11")                                 ;untick "Validate certificate CN against domain name"
      ControlClick($handle, "", "Button5")                                  ;click "invoke service/logon script"
      Sleep(500)
      ControlSend($handle, "", "Edit3" , $logonscript)                      ;input script into box
      ControlClick($handle, "", "Button12")                                 ;click "advance certificate/encryption options"
      Sleep(500)
   Local $handle2 = WinWait("Advanced Certificate/Encryption Options")
      WinActivate($handle2)
      ControlGetFocus($handle2, "")                                         ;confirm focus
      ControlClick($handle2, "", "Button13")                                ;Click "Choose Specific Cipher Suites"
      ControlClick($handle2, "", "Button10")                                ;Click "Select All"
      ControlClick($handle2, "", "Button8")                                 ;Click OK
   Local $handle3 = WinWait("Session Settings")
      WinActivate($handle3)
      ControlGetFocus($handle3, "")                                         ;confirm focus
      ControlClick($handle, "", "Button13")                                 ;Click OK
endFunc

Func LogonScript()


; GUI
local $gui = GUICreate("Auto Loader", 200, 150)

; LABEL
$Label_1 = GUICtrlCreateLabel("Please Enter Logon Script", 30, 10, 100, 20)

; Input
$Input_1 = GUICtrlCreateInput("TACL", 70, 20, 50, 20)

; BUTTON
$RUN_1 = GUICtrlCreateButton("OK", 50, 50, 100, 50)

; GUI MESSAGE LOOP
GUISetState()


While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $GUI_EVENT_CLOSE
            Exit
        Case $MSG = $RUN_1
           $script = GUICtrlRead($Input_1)
           GUIDelete($gui)
    EndSelect
Tooltip("Stuck in while1")
WEnd
Tooltip ("stuck in function")
EndFunc
Func Login2()
   Local $handle = WinWait("OutsideView - Untitled Workspace* - Tandem*")
   Sleep (2000)
   Send($script)
   Send ("{ENTER}")
EndFunc

It gets stuck at the end of the While 1 statement (I am using tooltips here to debug) and it doesn't exit the while loop properly.

I need whatever is typed into the text box to come back as a variable $script to continue logging in.

Any ideas?

Thanks!

Share this post


Link to post
Share on other sites



You need to exit the loop when deleting the GUI:
 

While 1
        $MSG = GUIGetMsg()
        Select
            Case $MSG = $GUI_EVENT_CLOSE
                Exit
            Case $MSG = $RUN_1
                $script = GUICtrlRead($Input_1)
                GUIDelete($gui)
                ExitLoop
        EndSelect
        ToolTip("Stuck in while1")
    WEnd

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
5 minutes ago, Jos said:

You need to exit the loop when deleting the GUI:
 

While 1
        $MSG = GUIGetMsg()
        Select
            Case $MSG = $GUI_EVENT_CLOSE
                Exit
            Case $MSG = $RUN_1
                $script = GUICtrlRead($Input_1)
                GUIDelete($gui)
                ExitLoop
        EndSelect
        ToolTip("Stuck in while1")
    WEnd

Jos

D'Oh!

Knew it had to be something stupid.  Thank you very much :)

Share this post


Link to post
Share on other sites

#4 ·  Posted

You can now EDIT solved ;)

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