cheeseslice Posted October 4, 2007 Share Posted October 4, 2007 i don't know if this is a stupid question or not but is it possible to have two forms within the one application? once the first part of my script has finished i want it to disappear and a new form to load with a new set of options and styles. thanks CS Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 4, 2007 Moderators Share Posted October 4, 2007 (edited) i don't know if this is a stupid question or not but is it possible to have two forms within the one application? once the first part of my script has finished i want it to disappear and a new form to load with a new set of options and styles. thanks CSYes it's possible... to make it easy on yourself, just put them in a function pseudo:_Form1() _Form2() Exit Func _Form1() gui stuff action stuff guidelete() return EndFunc Func _Form2() gui stuff action stuff guidelete() return EndFunc Edited October 4, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
cheeseslice Posted October 4, 2007 Author Share Posted October 4, 2007 Yes it's possible... to make it easy on yourself, just put them in a function pseudo:_Form1() _Form2() Exit Func _Form1() gui stuff action stuff guidelete() return EndFunc Func _Form2() gui stuff action stuff guidelete() return EndFunc thanks for the reply, this then brings me to another question. How can I have functions within functions? I have just tried the method you suggested and I am getting a syntax error at the first func within the _form1 function. Thanks again. Link to comment Share on other sites More sharing options...
i542 Posted October 4, 2007 Share Posted October 4, 2007 thanks for the reply, this then brings me to another question. How can I have functions within functions? I have just tried the method you suggested and I am getting a syntax error at the first func within the _form1 function. Thanks again.You do not need functions to run multiple forms.... Heres an example #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form 2", 340, 52, 199, 255) $Label2 = GUICtrlCreateLabel("The text you entered was:", 4, 6, 127, 17) $Label3 = GUICtrlCreateLabel("AutoIt Rocks", 6, 22, 303, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form 1", 316, 109, 193, 115) $Label1 = GUICtrlCreateLabel("Enter some text and click HitMe", 7, 11, 154, 17) $text = GUICtrlCreateInput("AutoIt Rocks", 8, 27, 121, 21) $Button1 = GUICtrlCreateButton("Hit Me", 7, 50, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GuiCtrlSetData($Label3, GuiCtrlRead($text)) EndSwitch WEnd I can do signature me. Link to comment Share on other sites More sharing options...
Nahuel Posted October 4, 2007 Share Posted October 4, 2007 Or... #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form 1", 316, 109, 193, 115) $Label1 = GUICtrlCreateLabel("Enter some text and click HitMe", 7, 11, 154, 17) $text = GUICtrlCreateInput("AutoIt Rocks", 8, 27, 121, 21) $Button1 = GUICtrlCreateButton("Hit Me", 7, 50, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form 2", 340, 52, 199, 255,-1,-1,$Form1) $Label2 = GUICtrlCreateLabel("The text you entered was:", 4, 6, 127, 17) $Label3 = GUICtrlCreateLabel("AutoIt Rocks", 6, 22, 303, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE If $nMsg[1]=$Form1 Then Exit Else GUIDelete($nMsg[1]) EndIf Case $Button1 GuiCtrlSetData($Label3, GuiCtrlRead($text)) EndSwitch WEnd This way there's only one button in the taskbar and you can close them individually. Except of course, if you close the main GUI. 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