Jump to content

Creating GUI from button already on GUI


Recommended Posts

I currently have a GUI that has to be called by a hotkeyset to open. This gui is where the user can go in and change variables for different circumstances, however, it's kind of large as there are around 20 variables. I'd like to have a gui that is always up (a smaller one in the corner) and have it contain a button that can be pressed and open the "set variables" GUI. I'm sure this has been answered at some point, but I couldn't seem to find exactly what I was looking for. I just really can't figure out how to make a child gui that reads input boxes, and can be saved, then closed, and have the main gui continue running. I want it to work where this "set Variables" gui can be opened at any time. I have tried this a couple of different ways, and just can't make it work. Thanks in advance.  

Link to comment
Share on other sites

Make the parent GUI be the GUI with the button, and have a child GUI that will always open. 

Have a look at this tutorial: Managing Multiple GUIs

P.S. Here is an example of how you would keep one variable the same and keep the main GUI on top, and up at the same time as the child.

#include <GUIConstants.au3>

; variable declarations
Global $pGUI, $cGUI, $msg, $iStored = 0, $pButton, $cButton = 9999, $input

; function call
MainGUI()

; main msg event loop
While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $pGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $pButton
                    ChildGUI()
            EndSwitch
        Case $cGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    GUIDelete($cGUI)
                Case $cButton
                    $iStored += 1
                    GUICtrlSetData($input, $iStored)
            EndSwitch
    EndSwitch
WEnd

; main gui function
Func MainGUI()
    $pGUI = GUICreate("MAIN GUI", 100, 80, -1, -1, $WS_SIZEBOX, $WS_EX_TOPMOST)
    WinMove("MAIN GUI", "", 0, 0)
    $pButton = GUICtrlCreateButton("Click Me", 15, 15)
    GUISetState(@SW_SHOW)
EndFunc   ;==>MainGUI

; main child gui function
Func ChildGUI()
    $cGUI = GUICreate("CHILD GUI", 150, 125, -1, -1, $WS_SIZEBOX)
    $cButton = GUICtrlCreateButton("Add 1", 5, 15)
    $input = GUICtrlCreateInput($iStored, 50, 15, 30, 15, $ES_READONLY)
    GUICtrlCreateLabel("if you close this, the" & @CRLF & "input will be the same.", 5, 50)
    GUISetState(@SW_SHOW)
EndFunc

Any questions? :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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