31290

GUI not working after being created

3 posts in this topic

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 ~~~

Share this post


Link to post
Share on other sites



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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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 ~~~

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

  • Similar Content

    • Skyrimfus
      By Skyrimfus
      How can i determine wich button was pressed when I use more than one button, without delcaring the button in a variable.
      Example:
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 600, 600, 192, 124) GUISetState(@SW_SHOW) For $i=0 to 5 GUICtrlCreateButton("Button"&$i,0,$i*50,60,30) Next #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case 3 to 8 MsgBox(0,0,"You pressed button:") EndSwitch WEnd  
    • Skyrimfus
      By Skyrimfus
      Is it possible for the graphic to be on top?
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### $Form1_1_1 = GUICreate("Form1", 804, 604, 192, 124) $Pic1 = GUICtrlCreatePic("car2.jpg", 656, 4, 118, 237) $Graphic1 = GUICtrlCreateGraphic(592, 4, 118, 237) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFF0000) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 2, 12, 34, 38) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 54, 12, 34, 38) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 17, 77, 34, 38) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 72, 70, 34, 38) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Now the car is on top of the squares, I can't get the squares to get on top of the car.
    • krasnoshtan
      By krasnoshtan
      Hello all! Recently I wanted to create settings window for my app, but if i want to close only child window, еhen all windows are closed. 
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("fisrt", 385, 248, 192, 114) $Button1 = GUICtrlCreateButton("settings", 40, 8, 97, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 sett() EndSwitch WEnd Func sett() $settings_window = GUICreate("settings", 380, 100, 100, 114) $exit_button = GUICtrlCreateButton("close", 34, 80, 9, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE MsgBox (0, "exit", "exit") Case $exit_button Exit EndSwitch WEnd EndFunc Help please!
    • anoig
      By anoig
      Hi all, 

      First, I want to give a huge shout-out to the community. I'm completely self-taught, and have never had to actually ask a question before because the forum is that good at answering questions and explaining things. However, I'm kind of stumped here, and I've been stuck on this problem for almost a full day.

      I'm working on a script to populate drafts of deeds at work. I have the main GUI and  a function (ctrl($n) and read()) for adding fields to find and data to replace it with to an array for later use with _word_docfindreplace. All of that works. However, due to the way I have the forms set up, I need to create additional fields and info based on the data that's there. Specifically, if there's only one buyer, I need to add the field [Buyer1&2] and the data in $aArray_Base for [Buyer 1]. I also need to add a field [Buyer 2] and have a blank data set in the next column over in the array, and I need to do the same for the Seller. To this end, the function parties() sets boolean variables $2buyers and $2sellers accordingly. Then, I have buyers() and sellers() to populate the data. 

      The problem that I'm running into is that each function works... when ONLY the buyer 1 name field is filled, and when ONLY the seller 1 field is filled.

      So if I fill Buyer 1 Name and save it, the data is populated correctly. But when I fill Buyer 1 and Seller 1 name, only the buyer 1 data populates correctly. Worse, when I fill several fields, neither populate correctly. I have no idea why this happens. I've added messageboxes to debug throughout the entire process and can't pinpoint what's causing the issue. The entire script is below. The function(s) in question are buyers() and sellers(). Only Sellers() has messageboxes throughout.

      Can someone help walk me through what might be causing this and help me find a solution? Thanks a ton in advance, and sorry for the wall of text.
      -Anoig
       
    • Skeletor
      By Skeletor
      Hi Guys,
      I've been reading this post ...
      When I came accross the examples, non of them had what I was looking for.
      I basically want to "snapshot" my GUI's multiple tabs and send them into the pdf.
      A little nudge from you guys would be great.
      Im really stuck with this one, therefore I have no code.
      Lets discuss or point me in a right direction... thanks alot