Sign in to follow this  
Followers 0
mlazovjp

Only one GUI window per script?

3 posts in this topic

Found this in the GUICreate() section of the help file:

This function always destroys the previous defined GUI

I want to be able to press a "Change Passwords" button and have a second window popup with input fields on it. Once the passwords are input, the use should press a "Verify Passwords" button on the second window that makes sure the two passwords match. If they do, then the password should be copied into a field on the original script window and then the Password window should disappear. This is what I do with my RapidQ version of the script.

For the moment, the current workaround with the AutoIt 3.x port of my script is to have a succession of Input boxes mimic the behavior of the one Passwords window.

Is what I am asking for do-able with the current version of AutoIt unstable? :D

Share this post


Link to post
Share on other sites



Here's some code quickly hacked out. You need to change the values of $AUTOIT and $HELPER to the appropriate paths.

When the helper window is called it saves it state to the AutoItWinTitle of the Main window. I need to add comments so help explain how it works.

See AutoBuilder in the scripts and scraps forum for more info. (Also in AutoBuilder, if Main is compiled, Helper.exe is launched; otherwise Helper.au3 is launched.)

Main.au3

#cs - ### Generated by AutoBuilder 0.4 -- do not modify ###
394 271
0   1   0   0   0   0   0   0   1   1   0   0   0   0   0   0   
button  $button_1   Button 1    40  40  220 50  0   0   
input   $input_1    Input 1 40  130 220 30  0   0   
#ce - ### End of Dump ###

$AUTOIT_ID_MAIN = "ExampleMainFoo"
$AUTOIT_ID_HELPER = "ExampleHelperFoo"

AutoItWinSetTitle($AUTOIT_ID_MAIN)

$AUTOIT = '"C:\AutoIt3.exe"'
$HELPER = '"C:\helper.au3"'

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI - Main", 392,266,(@DesktopWidth-392)/2, (@DesktopHeight-266)/2 , 0x04CF0000)

$button_1 = GUISetControl("button", "Button 1", 40, 40, 220, 50)
$input_1 = GUISetControl("input", "Input 1", 40, 130, 220, 30)

GuiShow()
While 1
    sleep(50)
    $msg = GuiMsg(0)
    $title = WinGetTitle($AUTOIT_ID_MAIN)
    If $title <> $AUTOIT_ID_MAIN Then
       $word = StringTrimLeft($title, StringInStr($title, @CRLF)+1)
       WinSetTitle($AUTOIT_ID_MAIN, "", $AUTOIT_ID_MAIN)
       GuiWrite($input_1, -1, "")
       GuiWrite($input_1, -1, $word)
   EndIF
    Select
    Case $msg = -3
        Exit
    Case $msg = $button_1
        Run($AUTOIT & " " & $HELPER)
    EndSelect
WEnd
Exit

Helper.au3

#cs - ### Generated by AutoBuilder 0.4 -- do not modify ###
394 271
0   2   0   0   0   0   0   0   2   2   0   0   0   0   0   0   
label   $label_1    Label 1 20  20  160 30  0   0   
input   $input_1    Input 1 70  50  220 30  0   0   
label   $label_2    Label 2 20  110 160 30  0   0   
input   $input_2    Input 2 70  140 220 30  0   0   
button  $button_1   Button 1    40  220 120 30  0   0   
button  $button_2   Button 2    190 220 110 30  0   0   
#ce - ### End of Dump ###

$AUTOIT_ID_MAIN = "ExampleMainFoo"
$AUTOIT_ID_HELPER = "ExampleHelperFoo"

AutoItWinSetTitle($AUTOIT_ID_HELPER)

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI - Helper", 392,266,(@DesktopHeight-392)/2, (@DesktopHeight-266)/2 , 0x04CF0000)

$label_1 = GUISetControl("label", "First Time", 20, 20, 160, 30)
$input_1 = GUISetControl("input", "", 70, 50, 220, 30)
GUISetControlEx($input_1, 256);GUI_FOCUS
$label_2 = GUISetControl("label", "Second Time", 20, 110, 160, 30)
$input_2 = GUISetControl("input", "", 70, 140, 220, 30)
$button_1 = GUISetControl("button", "Submit", 40, 220, 120, 30)
$button_2 = GUISetControl("button", "Cancel", 190, 220, 110, 30)

GuiShow()

While 1
    sleep(50)
    $msg = GuiMsg(0)
    Select
    Case $msg = -3
        Exit
     Case $msg = $button_1
         $word = GuiRead($input_1)
        If $word <> GuiRead($input_2) Then
            MsgBox(4096,"Error", "Words do not match; try again")
            GUIWrite($input_1, -1, "")
            GUIWrite($input_2, -1, "")
            ControlFocus("MyGUI - Helper", "", "Edit1")
        Else
           ; Change title of the main window, not this helper window
            WinSetTitle($AUTOIT_ID_MAIN, "", $AUTOIT_ID_MAIN & @CRLF & $word)
            Exit
        EndIF
    Case $msg = $button_2
        GUIWrite($input_1, -1, "")
        GUIWrite($input_2, -1, "")
    EndSelect
WEnd
Exit

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Here's some code quickly hacked out.  You need to change the values of $AUTOIT and $HELPER to the appropriate paths.

When the helper window is called it saves it state to the AutoItWinTitle of the Main window.  I need to add comments so help explain how it works.

See AutoBuilder in the scripts and scraps forum for more info.  (Also in AutoBuilder, if Main is compiled, Helper.exe is launched; otherwise Helper.au3 is launched.)

Thanks.

I'll take a look at that.

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