beanwi Posted November 24, 2008 Share Posted November 24, 2008 Me and my friend are attempting to create a text based game using autoit this is the script we have so far..... CODE;GUI Interface Include File #include <WindowsConstants.au3> ;Creating GUI and Styles GUICreate ("TIMMY", 400, 400) GUISetState () GUISetStyle ($WS_Caption) ;Creating GUI Buttons $HelpButton = GUICtrlCreateButton ( "HELP FILE", 1, 1, 60, 20) $ExitButton = GUICtrlCreateButton ( "Exit", 61, 1, 60, 20) ;Setting Button Parameters While 1 $Msg = GUIGetMsg() Select Case $Msg = $HelpButton GUICreate ("2ndwindow", 200, 200) GUISetState() GUISetStyle ($WS_Caption) $HelpExitButton = GUICtrlCreateButton ( "Exit", 1, 1, 60, 20) While 1 $Msg2 = GUIGetMsg() Select Case $Msg2 = $HelpExitButton GUIDelete () EndSelect WEnd Case $Msg = $ExitButton ExitLoop EndSelect WEnd ;Closing Statement MsgBox (0,"Thank You", "Thank you for playing") the problem is that when the GUI first opens both buttons work, but then when the 2nd GUI window opens and you close it the buttons no longer work... if anyone could help that would be great Link to comment Share on other sites More sharing options...
zorphnog Posted November 24, 2008 Share Posted November 24, 2008 This is what we like to call an endless loop! You must exit the While loop after you delete the gui. #include <WindowsConstants.au3> ;Creating GUI and Styles GUICreate ("TIMMY", 400, 400) GUISetState () GUISetStyle ($WS_Caption) ;Creating GUI Buttons $HelpButton = GUICtrlCreateButton ( "HELP FILE", 1, 1, 60, 20) $ExitButton = GUICtrlCreateButton ( "Exit", 61, 1, 60, 20) ;Setting Button Parameters While 1 $Msg = GUIGetMsg() Select Case $Msg = $HelpButton GUICreate ("2ndwindow", 200, 200) GUISetState() GUISetStyle ($WS_Caption) $HelpExitButton = GUICtrlCreateButton ( "Exit", 1, 1, 60, 20) While 1 $Msg2 = GUIGetMsg() Select Case $Msg2 = $HelpExitButton GUIDelete () ExitLoop EndSelect WEnd Case $Msg = $ExitButton ExitLoop EndSelect WEnd ;Closing Statement MsgBox (0,"Thank You", "Thank you for playing") Link to comment Share on other sites More sharing options...
beanwi Posted November 24, 2008 Author Share Posted November 24, 2008 (edited) This is what we like to call an endless loop! You must exit the While loop after you delete the gui. #include <WindowsConstants.au3> ;Creating GUI and Styles GUICreate ("TIMMY", 400, 400) GUISetState () GUISetStyle ($WS_Caption) ;Creating GUI Buttons $HelpButton = GUICtrlCreateButton ( "HELP FILE", 1, 1, 60, 20) $ExitButton = GUICtrlCreateButton ( "Exit", 61, 1, 60, 20) ;Setting Button Parameters While 1 $Msg = GUIGetMsg() Select Case $Msg = $HelpButton GUICreate ("2ndwindow", 200, 200) GUISetState() GUISetStyle ($WS_Caption) $HelpExitButton = GUICtrlCreateButton ( "Exit", 1, 1, 60, 20) While 1 $Msg2 = GUIGetMsg() Select Case $Msg2 = $HelpExitButton GUIDelete () ExitLoop EndSelect WEnd Case $Msg = $ExitButton ExitLoop EndSelect WEnd ;Closing Statement MsgBox (0,"Thank You", "Thank you for playing") the reason i wanted an endless loop is because i wanted it to loop the cases until i pressed the exit button, because theres an exit loop command in the $exitbutton variable, so i want the original GUI window to stay up after i close the help window Edited November 24, 2008 by beanwi Link to comment Share on other sites More sharing options...
Valuater Posted November 24, 2008 Share Posted November 24, 2008 This is how I do it!!! #include <WindowsConstants.au3> ;Creating GUI and Styles $GUI_1 = GUICreate("TIMMY", 400, 400) GUISetStyle($WS_Caption) $HelpButton = GUICtrlCreateButton("HELP FILE", 1, 1, 60, 20) $ExitButton = GUICtrlCreateButton("Exit", 61, 1, 60, 20) GUISetState() ; GUI #2 $GUI_2 = GUICreate("2ndwindow", 200, 200) GUISetStyle($WS_Caption) $HelpExitButton = GUICtrlCreateButton("Exit", 1, 1, 60, 20) GUISetState(@SW_HIDE, $GUI_2) ;Setting Button Parameters While 1 $Msg = GUIGetMsg() Select Case $Msg = $HelpButton GUISetState(@SW_SHOW, $GUI_2) Case $Msg = $HelpExitButton GUISetState(@SW_HIDE, $GUI_2) Case $Msg = $ExitButton ExitLoop EndSelect WEnd ;Closing Statement MsgBox(0, "Thank You", "Thank you for playing") 8) Link to comment Share on other sites More sharing options...
beanwi Posted November 24, 2008 Author Share Posted November 24, 2008 This is how I do it!!! #include <WindowsConstants.au3> ;Creating GUI and Styles $GUI_1 = GUICreate("TIMMY", 400, 400) GUISetStyle($WS_Caption) $HelpButton = GUICtrlCreateButton("HELP FILE", 1, 1, 60, 20) $ExitButton = GUICtrlCreateButton("Exit", 61, 1, 60, 20) GUISetState() ; GUI #2 $GUI_2 = GUICreate("2ndwindow", 200, 200) GUISetStyle($WS_Caption) $HelpExitButton = GUICtrlCreateButton("Exit", 1, 1, 60, 20) GUISetState(@SW_HIDE, $GUI_2) ;Setting Button Parameters While 1 $Msg = GUIGetMsg() Select Case $Msg = $HelpButton GUISetState(@SW_SHOW, $GUI_2) Case $Msg = $HelpExitButton GUISetState(@SW_HIDE, $GUI_2) Case $Msg = $ExitButton ExitLoop EndSelect WEnd ;Closing Statement MsgBox(0, "Thank You", "Thank you for playing") 8) thanks for the help, i didnt even think about hiding it Link to comment Share on other sites More sharing options...
Valuater Posted November 24, 2008 Share Posted November 24, 2008 (edited) thanks for the help, i didnt even think about hiding itWell, I commend your "thinking" for your first post/thread... Welcome to the Autoit Forums!!!8) Edited November 24, 2008 by Valuater Link to comment Share on other sites More sharing options...
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