Jump to content

GUI not working after being created


31290
 Share

Recommended Posts

Hi everyone, 

 

I'm facing a little issue here. After creating a GUI coming from a button action, the GUI seems not to work anymore. 

Here's what I wrote so far:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <TabConstants.au3>
#include <EditConstants.au3>
#include <AD.au3>
#include <GuiTab.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <ColorConstants.au3>
#include <ComboConstants.au3>
#Include <Constants.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <File.au3>
#Include <FontConstants.au3>
#include <GuiEdit.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <Inet.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <ProgressConstants.au3>
#include <ScreenCapture.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1) ; Only needed once

Global $sT0_AdminUserName, $sT0_AdminUserPassword, $sT0_DomainName, $sT0_DomainController, $sT0_ConfigurationContext, $iRunning, $aGroup, $sGroup, $i
Global $resources = "C:\SAC_IS\AD_Toolbox\Resources\"
Global $workingDir = "C:\SAC_IS\AD_Toolbox\"
Global $logs = $Resources &"\Logs\"
Global $iAlgo = $CALG_RC4
Global $g_hKey = "CryptPassword"
Global $sIniFile = $resources & "\AD_Toolbox_" & @UserName & ".ini"

DirCreate ($WorkingDir)
DirCreate ($resources)
DirCreate ($logs)


Func chooseComputerTypeGUI()
Global $chooseComputerTypeGUI = GUICreate("AD GROUPS", 300, 300, -1, -1)
GUICtrlCreatePic ($resources & "\SAClogo.jpg", 30, 10, 240, 80)
GUISetFont(8.5, 700, 0)
GUISetBkColor ($Color_White)
GUICtrlCreateLabel("Active Directory TOOLBOX", 85, 100, 150, 25)
GuiCtrlCreateSeperator(0, 10, 120, 2, 280)
GUICtrlCreateLabel("Please choose on what you will work on:", 30, 140)
$desktopBtn = GUICtrlCreateButton("A DESKTOP", 10, 170, 110, 50)
$laptopBtn = GUICtrlCreateButton("A LAPTOP", 180, 170, 110, 50)
$userBtn = GUICtrlCreateButton("A USER", 95, 240, 110, 50)
;Buttons Actions
GUICtrlSetOnEvent($desktopBtn, "desktopMainGUI")
GUICtrlSetOnEvent($laptopBtn, "laptopMainGui")
GUICtrlSetOnEvent($userBtn, "userMainGui")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $chooseComputerTypeGUI)
GUISetState()
$iRunning = 1
While $iRunning = 1
Sleep (10)
Wend
EndFunc


Func userMainGui()
Global $addDefaultGroupsGUI = GUICreate("AD GROUPS", 300, 300, -1, -1)
GUICtrlCreatePic ($resources & "\SAClogo.jpg", 30, 10, 240, 80)
GUISetFont(8.5, 700, 0)
GUISetBkColor ($Color_White)
GUICtrlCreateLabel("Active Directory TOOLBOX", 85, 100, 150, 25)
GUICtrlCreateLabel("Enter a End User Global ID:", 10, 130)
GUICtrlSetColor(-1, $COLOR_PURPLE)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $addDefaultGroupsGUI)
GUISetState()
$iRunning = 1
While $iRunning = 1
Sleep (10)
Wend
GUIDelete($chooseComputerTypeGUI)
userMainGui()
EndFunc

I think I'm lost here. Thanks for giving a hand :)

~~~ Doom Shall Never Die, Only The Players ~~~

Link to comment
Share on other sites

  • Moderators

31290,

It is hardly surprising that nothing is working - in each of the functions in that you have an infinite loop with no means of escape:

$iRunning = 1
While $iRunning = 1
    Sleep(10)
WEnd

Nowhere do you set $iRunning to 0 and allow the loops to end.

Besides, you should always return to an idle loop in the main script once a function ends - if you remain inside a function, in most cases AutoIt will not acknowledge calls to other functions.

And why do you have a recursive call to userMainGui()? What do you expect to happen?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba23, 

Thanks for answering.

And why do you have a recursive call to userMainGui()? What do you expect to happen?

M23

That's a mistake I made, I'd call that a "mispaste" ^^

 

Nowhere do you set $iRunning to 0 and allow the loops to end.

Besides, you should always return to an idle loop in the main script once a function ends - if you remain inside a function, in most cases AutoIt will not acknowledge calls to other functions.

$irunning is set to 0 in an other function I did not paste earlier: I don't know if this is enough because this function is only called at the very beginning of the script

Func _Submit()
    Global $GID = GuiCtrlRead($GIDTechInput)
    Global $password = GUICtrlRead($PassInput)
    If FileExists ($sIniFile) Then
    GUIDelete ($LoginfoGUI)
    $irunning = 0
    Else
    IniWrite ($sIniFile, "ADTB", "DomainName", "XXXX")
    IniWrite ($sIniFile, "ADTB", "DomainController", "XXXX")
    IniWrite ($sIniFile, "ADTB", "ConfigurationContext", "CN=Configuration,DC=XXXX,DC=XXXX")
    $irunning = 0
    EndIf
EndFunc

For now, having deleted every loop in sub functions is working.

Hope this will be enough for the rest of the soft, I'll see. But in any cases, I understand better now.

Thanks :)

~~~ Doom Shall Never Die, Only The Players ~~~

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

×
×
  • Create New...