DoubleMcLovin Posted July 22, 2010 Posted July 22, 2010 My code uses function calls within the GUI to bounce through various commands, but after a string of commands reaches the point where they complete and I would think I would be sent back to my original window, all of my windows close. Here is the piece of script controlled the GUI I want to keep open until closed expandcollapse popup#Region ;Text Client $outputtext = $MOTD $TextClient = GUICreate("RPG Bot", 625, 443, 225, 248, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_VSCROLL,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetBkColor(0x000000) $input = GUICtrlCreateInput("", 0, 420, 601, 23, $WS_BORDER) GUICtrlSetFont(-1, 8, 400, 0, "Fixedsys") GUICtrlSetColor(-1, 0x000000) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $output = GUICtrlCreateLabel($outputtext, 5, 5, 600, 395) GUICtrlSetFont(-1, 8, 400, 0, "Fixedsys") GUICtrlSetColor(-1, 0xC8C8C8) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER) GUISetState(@SW_SHOW) #EndRegion ;Text Client $outputtext = $outputtext & @CRLF & "Would you like to start a new game? Y/N" & @CRLF GUICtrlSetData($output,$outputtext) While 1 $TCMsg = GUIGetMsg() Select Case $TCMsg = $GUI_EVENT_CLOSE ;~ Quit() Exit ; Remove the straight exit and add a quit function Case $TCMsg = $input $line = GUICtrlRead($input) $outputtext = $outputtext & @CRLF & "DoubleMcLovin: " & GUICtrlRead($input) GUICtrlSetData($output,$outputtext) GUICtrlSetData($input,"") If $line = "Y" Or $line = "Yes" Then $outputtext = $outputtext & @CRLF & "Loading the character creation screen..." & @CRLF GUICtrlSetData($output,$outputtext) $NG = 1 ExitLoop ElseIf $line = "N" Or $line = "No" Then $outputtext = $outputtext & @CRLF & "Loading the save game selection screen..." & @CRLF GUICtrlSetData($output,$outputtext) $NG = 2 ExitLoop Else $outputtext = $outputtext & @CRLF & "I didn't quite get that, could you try again?" & @CRLF GUICtrlSetData($output,$outputtext) $outputtext = $outputtext & @CRLF & "Would you like to start a new game? Y/N" & @CRLF GUICtrlSetData($output,$outputtext) EndIf EndSelect WEnd If $NG = 1 Then ; loads a new game CharacterCreate() ElseIf $NG = 2 Then ; loads a saved game $CPFile = FileOpenDialog( "Open Saved Game", $CPDir, "*.cprf") EndIf
Moderators Melba23 Posted July 22, 2010 Moderators Posted July 22, 2010 DoubleMcLovin,Difficult to say without seeing more code, but from your post I assume you have a number of GUIs open simultaneously. If this the case, then you may well need to use the advanced parameter with GUIGetMsg so you can determine which GUI has sent what message.At the moment, receiving the $GUI_EVENT_CLOSE message from any window will fire the Exit code - which could well be the problem.Here is a short example of using GUIGetMsg with the advanced parameter to show how to use it:expandcollapse popup#include <GUIConstantsEx.au3> Global $hGUI2 = 9999, $hButton3 = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements gui1() Func gui1() $hGUI1 = GUICreate("Gui 1", 500, 500) $hButton1 = GUICtrlCreateButton("Show Gui 2", 10, 10, 80, 30) $hButton2 = GUICtrlCreateButton("Msgbox 1", 10, 60, 80, 30) GUISetState() While 1 $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array Switch $aMsg[1] ; check which GUI sent the message Case $hGUI1 Switch $aMsg[0] ; Now check for the messages for $hGUI1 Case $GUI_EVENT_CLOSE ExitLoop Case $hButton1 GUICtrlSetState($hButton1, $GUI_DISABLE) gui2() Case $hButton2 MsgBox("", "MsgBox 1", "Test from Gui 1") EndSwitch Case $hGUI2 Switch $aMsg[0] ; Now check for the messages for $hGUI2 Case $GUI_EVENT_CLOSE GUIDelete($hGUI2) GUICtrlSetState($hButton1, $GUI_ENABLE) Case $hButton3 MsgBox("", "MsgBox", "Test from Gui 2") EndSwitch EndSwitch WEnd EndFunc ;==>gui1 Func gui2() $hGUI2 = GUICreate("Gui 2", 200, 200, -1, -1) $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30) GUISetState() EndFunc ;==>gui2I hope this helps. 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
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