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

    • jannikrendl
      By jannikrendl
      Hey guys,
      I was trying to create a script with a GUI but when I start the script via pressing the startbutton in my GUI and then trying to stop the script it won't close/stop.
      Here is the script:
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $GUI = GUICreate("AlphaAgility", 218, 65, 1147, 123) Global $StartButton = GUICtrlCreateButton("Start", 24, 16, 75, 25) Global $StopButton = GUICtrlCreateButton("Stop", 120, 16, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $StartButton while(1) Agility() WEnd Case $StopButton Exit EndSwitch WEnd Global $agility = False Func Agility() MouseClick("Left",random(466,500),random(634,669),1,random(10,20));Balancier-Stamm If Not(@error) Then $agility = True sleep(random(0,200)) MouseMove(random(408,661),random(632,749),random(10,20));random Mousemovement Balancier-Stamm Else EndIf sleep(5500) MouseClick("Left",448,820,1,random(10,20));Netz If Not(@error) Then $agility = True sleep(random(0,200)) MouseMove(random(334,557),random(774,876),random(10,20));random Mousemovement Netz Else $agility = False EndIf sleep(3750) MouseClick("Left",480,706,1,random(10,20));Ast If Not(@error) Then $agility = True ;sleep(random(0,200)) ;MouseMove(random(95,953),random(117,1067),random(10,20)) -> kein random Mousemovement nötig Else $agility = False EndIf sleep(2750) MouseClick("Left",727,608,1,random(10,20));Balancier-Seil If Not(@error) Then $agility = True sleep(random(0,200)) MouseMove(random(723,891),random(572,676),random(10,20));random Mousemovement Balancier-Seil Else $agility = False EndIf sleep(6750) MouseClick("Left",698,633,1,random(10,20));Ast If Not(@error) Then $agility = True ;sleep(random(0,200)) ;MouseMove(random(95,953),random(117,1067),random(10,20)) -> kein random Mousemovement nötig Else $agility = False EndIf sleep(4000) MouseClick("Left",random(372,459),random(136,202),1,random(10,20));Netz If Not(@error) Then $agility = True sleep(random(0,200)) MouseMove(random(388,510),random(140,212),random(10,20));random Mousemovement Netz Else $agility = False EndIf sleep(6250) MouseClick("Left",random(362,401),random(363,409),1,random(10,20));Röhre If Not(@error) Then $agility = True ;sleep(random(0,200)) ;MouseMove(random(95,953),random(117,1067),random(10,20)) -> kein random Mousemovement nötig Else $agility = False EndIf sleep(7000) MouseClick("Left",14,654,1,random(10,20));Startposition If Not(@error) Then $agility = True ;sleep(random(0,200)) ;MouseMove(random(388,510),random(140,212),random(10,20)) -> kein random Mousemovement nötig Else EndIf sleep(4000) EndFunc Thanks in advance
      Jannik Rendl
    • nlta1992
      By nlta1992
      I want creat GUI, have button 1 to 10, but only use loop for ... to ... step ... next.
      Thanks.
    • ur
      By ur
      We are trying to automate the installation testing before sending to end users, our product.
      For Silent Installation, we have completed this part.
      But for GUI, the default installation is completed by sending the keys based on the window.
      But for GUI custom installation, we are struck.
      How to enable or disable features in the below screen using GUI automation.?

    • fopetesl
      By fopetesl
      OK, still learning SOLVED! $WS_EX_COMPOSITED hides buttons?
      I've read, run examples but cannot show action buttons in tabs in a GUI.
      I've run the GUICtrlCreateTabItem function example and, of course, it works.
      Mine doesn't:
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <MenuConstants.au3> #include <TabConstants.au3> #include <ColorConstants.au3> $hGUI = GUICreate("My GUI Tab", @DesktopWidth * 1, @DesktopHeight * 1, 0, 0,-1, $WS_EX_COMPOSITED) $hTab = GUICtrlCreateTab(10, 10, 640, 480,$TCS_HOTTRACK) ; Create tabitems ;For $i = 0 To 2 GUICtrlCreateTabItem(" Scan Sample ") ; $idButton1 = GUICtrlCreateButton("Button " & 0, 20 + (0 * 100), 40 + (0 * 50), 80, 30) ; $idButton1 = GUICtrlCreateButton("00", 20, 50, 80, 30) GUICtrlCreateLabel("label0", 30, 80, 50, 20) GUICtrlCreateButton("OK0", 20, 50, 50, 20) GUICtrlCreateInput("default", 80, 50, 70, 20) GUICtrlCreateTabItem(" Database ") GUICtrlCreateButton("Button " & 1, 20 + (1 * 100), 40 + (1 * 50), 80, 30) GUICtrlCreateTabItem(" Software ") GUICtrlCreateButton("Button " & 2, 20 + (2 * 100), 40 + (2 * 50), 80, 30) ;Next ; Close Tab definiton GUICtrlCreateTabItem("") ; Set the color of the label control. ; GUICtrlSetColor($idButton1, 0x002E7A) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd It just shows:
      whatever I try.  So I've missed, again?, that I do not have the focus?
       
    • drapdv
      By drapdv
      I have a GUI with a parent window that has a menu and shortcut buttons at the top, and a child window which displays a list which is scrolled vertically.
      When the list is relatively small, like no more than 100 or so lines then it scrolls fine.  As the list gets larger, scrolling begins to slow, and if you start mixing up the scroll method (mousewheel, left-clicking the scrollbar box, etc) then it begins to hang.  When it hangs, dwm.exe CPU usage maxes out, and I can't even switch to another window.  Each line in the list is 1000px wide X 30px tall, and the lines alternate between a gray background and a white background, in case that matters.
      When a non-Aero theme is active, everything works fine.  So, I could disable DWM every time someone fires it up, but changing a client's color scheme is not ideal.
      I tried to utilize _WinAPI_DwmSetWindowAttribute($oGui_Parent,  $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED), and although it succeeds in disabling DWM for that window, it doesn't seem to make any difference as far as the scrolling lag is concerned.
      The code is several thousand lines long and contains proprietary information, so I'm trying to avoid posting that, but these are the lines which are creating the GUIs.  Is there anything that anyone can think of off the top of their heads, or is there anything jumping out at you from this snippet of code?  Any help is appreciated!
      $oGui_Parent = GUICreate("Data Viewer", 700, 500, Default, Default, BitOR($WS_CAPTION, $WS_MINIMIZEBOX, $WS_POPUPWINDOW)) WinSetTrans($oGui_Parent, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Parent, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF) $oGui_Child = GUICreate("", 700, 400, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $oGui_Parent) WinSetTrans($oGui_Child, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Child, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF)