31290 Posted September 21, 2015 Posted September 21, 2015 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:expandcollapse popup#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() EndFuncI think I'm lost here. Thanks for giving a hand ~~~ Doom Shall Never Die, Only The Players ~~~
Moderators Melba23 Posted September 21, 2015 Moderators Posted September 21, 2015 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) WEndNowhere 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
31290 Posted September 21, 2015 Author Posted September 21, 2015 Melba23, Thanks for answering.And why do you have a recursive call to userMainGui()? What do you expect to happen?M23That'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 scriptFunc _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 EndFuncFor 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 ~~~
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now