Jump to content
Sign in to follow this  
gnomic

Restart/reset buttons location

Recommended Posts

gnomic

Hey,

If i have a button that runs a function, which shows many buttons in the GUI - how can i restart/reset/clear it all, so the function buttons, isnt there anymore?

any help is appriciated, thanks

Share this post


Link to post
Share on other sites
water

Can you post the code so we can see what you are talking about?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
gnomic

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("Test", 600, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$_menu1 = GUICtrlCreateButton("Menu 1", 10, 10, 80)
GUICtrlSetOnEvent($_menu1, "_Menu1")
$_menu2 = GUICtrlCreateButton("Menu 2", 100, 10, 80)
GUICtrlSetOnEvent($_menu2, "_Menu2")
Func _Menu1()
   $_test1 = GUICtrlCreateButton("Test 1", 10, 50, 60)
   GUICtrlSetOnEvent($_test1, "_Test1")
   $_test2 = GUICtrlCreateButton("Test 2", 80, 50, 60)
   GUICtrlSetOnEvent($_test2, "_Test2")
EndFunc
Func _Menu2()
   $_test3 = GUICtrlCreateButton("Test 3", 10, 50, 60)
   GUICtrlSetOnEvent($_test3, "_Test3")
   $_test4 = GUICtrlCreateButton("Test 4", 80, 50, 60)
   GUICtrlSetOnEvent($_test4, "_Test4")
EndFunc
GUISetState(@SW_SHOW)
While 1
  Sleep(1000)  ; Idle around
WEnd
Func CLOSEClicked()
  Exit
EndFunc

Share this post


Link to post
Share on other sites
water

You could use "GUICtrlDelete" for each button to delete it when it is no longer needed.

Or you could use Tabs to present a new "GUI" whenever a menu button is clicked.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
gnomic

thanks :)

Share this post


Link to post
Share on other sites
water

Here's an example of a very general tab GUI I use in one of my Active Directory tools:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <TabConstants.au3>
#include <EditConstants.au3>
#include <GuiTab.au3>


Global $sTitle = "ADAT - Active Directory Admin Tool"
Global $iCurrTab = 0, $iPrevTab = 0, $iMsg, $iResult, $iLine, $sIniFile = @ScriptDir & "ADAT.INI"
Global $bIsConnected = False, $sReturnValue = ""
#region ### Hold the input of the GUI ###
Global $sT0_AdminUserName, $sT0_AdminUserPassword, $sT0_DomainName, $sT0_DomainController, $sT0_ConfigurationContext
Global $sT1_ComputerName, $sT1_OU, $sT1_Usergroup, $sT1_Description
Global $sT2_ComputerName, $sT2_UserID, $sT2_Password
Global $sT3_UserID
#endregion ### Hold the input of the GUI ###
#region ### Position and dimension of controls ###
Global $iDLeft = 16, $iDTop = 38, $iDWidth = 600, $iDHeight = 17 ; description line
Global $iLLeft = 16, $iLTop = 74, $iLWidth = 191, $iLHeight = 17, $iLSpace = 17 ; Label control
Global $iILeft = 208, $iITop = 72, $iIWidth = 209, $iIHeight = 21, $iISpace = 13 ; Input control
Global $iBLeft = 426, $iBTop = 72, $iBWidth = 25, $iBHeight = 21, $iBSpace = 13 ; Addional Button control
#endregion ### Position and dimension of controls ###
; Fill the fields of the "General" tab from an INI file
$sT0_AdminUserName = IniRead($sIniFile, "ADAT", "AdminUserName", "")
$sT0_DomainName = IniRead($sIniFile, "ADAT", "DomainName", "")
$sT0_DomainController = IniRead($sIniFile, "ADAT", "DomainController", "")
$sT0_ConfigurationContext = IniRead($sIniFile, "ADAT", "ConfigurationContext", "")
#region ### START Koda GUI section ###
Global $hGUI = GUICreate($sTitle, 625, 448, 192, 124)
Global $hTab = GUICtrlCreateTab(8, 8, 609, 400, BitOR($GUI_SS_DEFAULT_TAB, $TCS_MULTILINE))
;---------------
; Tab 0: General
;---------------
$iLine = 0
Global $hT0 = GUICtrlCreateTabItem("&General")
GUICtrlCreateLabel("Enter admin credentials to be used for all other functions or empty for the current user.", $iDLeft, $iDTop, $iDWidth, $iDHeight)
GUICtrlSetFont(-1, 9, 800) ; bold
; Line 1
GUICtrlCreateLabel("Admin user name", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT0_AdminUserName = GUICtrlCreateInput($sT0_AdminUserName, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
GUICtrlSetState(-1, $GUI_Focus)
; Line 2
$iLine += 1
GUICtrlCreateLabel("Admin user password", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT0_AdminUserPassword = GUICtrlCreateInput("", $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
; Line 3
$iLine += 1
GUICtrlCreateLabel("Active Directory domain name", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT0_DomainName = GUICtrlCreateInput($sT0_DomainName, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
; Line 4
$iLine += 1
GUICtrlCreateLabel("Name of Domain Controller", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT0_DomainController = GUICtrlCreateInput($sT0_DomainController, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
; Line 5
$iLine += 1
GUICtrlCreateLabel("Configuration naming context", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT0_ConfigurationContext = GUICtrlCreateInput($sT0_ConfigurationContext, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
;-----------------------
; Tab 1: Create computer
;-----------------------
$iLine = 0
Global $hT1 = GUICtrlCreateTabItem("&Create Computer")
GUICtrlCreateLabel("Create a computer in the specified OU.", $iDLeft, $iDTop, $iDWidth, $iDHeight)
GUICtrlSetFont(-1, 9, 800) ; bold
; Line 1
GUICtrlCreateLabel("Computername", $iLLeft, 74, $iLWidth, $iLHeight)
Global $hT1_ComputerName = GUICtrlCreateInput(@ComputerName, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
Global $hT1_ButtonComputer = GUICtrlCreateButton("...", $iBLeft, $iBTop + $iLine * $iBHeight + $iLine * $iBSpace, $iBWidth, $iBHeight)
; Line 2
$iLine += 1
GUICtrlCreateLabel("OU to create the computer in", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT1_OU = GUICtrlCreateInput("", $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
Global $hT1_ButtonOU = GUICtrlCreateButton("...", $iBLeft, $iBTop + $iLine * $iBHeight + $iLine * $iBSpace, $iBWidth, $iBHeight)
; Line 3
$iLine += 1
GUICtrlCreateLabel("User/group allowed to join the comp.", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT1_Usergroup = GUICtrlCreateInput(@UserName, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
; Line 4
$iLine += 1
GUICtrlCreateLabel("Description", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT1_Description = GUICtrlCreateInput("", $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
;---------------------
; Tab 2: Join computer
;---------------------
$iLine = 0
Global $hT2 = GUICtrlCreateTabItem("&Join Computer")
GUICtrlCreateLabel("Join the specified computer to the domain defined on the 'General' tab.", $iDLeft, $iDTop, $iDWidth, $iDHeight)
GUICtrlSetFont(-1, 9, 800) ; bold
; Line 1
GUICtrlCreateLabel("Computername", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT2_ComputerName = GUICtrlCreateInput(@ComputerName, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
Global $hT2_ButtonComputer = GUICtrlCreateButton("...", $iBLeft, $iBTop + $iLine * $iBHeight + $iLine * $iBSpace, $iBWidth, $iBHeight)
; Line 2
$iLine += 1
GUICtrlCreateLabel("User name", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT2_UserID = GUICtrlCreateInput($sT2_UserID, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
Global $hT2_ButtonUser = GUICtrlCreateButton("...", $iBLeft, $iBTop + $iLine * $iBHeight + $iLine * $iBSpace, $iBWidth, $iBHeight)
; Line 3
$iLine += 1
GUICtrlCreateLabel("User password", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT2_Password = GUICtrlCreateInput("", $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
;-----------------------------
; Tab 3: Query user properties
;-----------------------------
$iLine = 0
Global $hT3 = GUICtrlCreateTabItem("Query &user properties")
GUICtrlCreateLabel("Show properties of the selected user.", $iDLeft, $iDTop, $iDWidth, $iDHeight)
GUICtrlSetFont(-1, 9, 800) ; bold
; Line 1
GUICtrlCreateLabel("Username", $iLLeft, $iLTop + $iLine * $iLHeight + $iLine * $iLSpace, $iLWidth, $iLHeight)
Global $hT3_UserID = GUICtrlCreateInput(@UserName, $iILeft, $iITop + $iLine * $iIHeight + $iLine * $iISpace, $iIWidth, $iIHeight)
Global $hT3_ButtonUser = GUICtrlCreateButton("...", $iBLeft, $iBTop + $iLine * $iBHeight + $iLine * $iBSpace, $iBWidth, $iBHeight)
;---------------------------
; Terminate the tab creation
;---------------------------
GUICtrlCreateTabItem("")
;---------------------
; Buttons for all tabs
;---------------------
Global $hButton_Process = GUICtrlCreateButton("Process", 8, 416, 97, 25)
Global $hButton_Exit = GUICtrlCreateButton("Exit", 517, 415, 97, 25)
#endregion ### END Koda GUI section ###
GUISetState(@SW_SHOW)
While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $hButton_Exit
            Exit
        Case $hButton_Process
            $iCurrTab = GUICtrlRead($hTab)
;            Call("Process_Tab" & $iCurrTab)
        Case $hTab
            $iPrevTab = $iCurrTab
            $iCurrTab = GUICtrlRead($hTab)
            ; Set the focus to the first input field on every tab
            #region ### Set focus ###
            If $iCurrTab = 0 Then GUICtrlSetState($hT0_AdminUserName, $GUI_Focus)
            If $iCurrTab = 1 Then GUICtrlSetState($hT1_ComputerName, $GUI_Focus)
            If $iCurrTab = 2 Then GUICtrlSetState($hT2_ComputerName, $GUI_Focus)
            If $iCurrTab = 3 Then GUICtrlSetState($hT3_UserID, $GUI_Focus)
            #endregion ### Set focus ###
        #region ### Process buttons ###
        Case $hT1_ButtonOU ; Display a treeview of the OUs and let the user select one
        Case $hT1_ButtonComputer, $hT2_ButtonComputer ; List all computers and let the user select one
        Case $hT2_ButtonUser, $hT3_ButtonUser
        #endregion ### Process buttons ###
    EndSwitch
WEnd

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×