Michael36 Posted November 11, 2005 Share Posted November 11, 2005 Hi All can we use two Guis in one script example would be click a button to show a second gui if fact i'm sure we can do this i just can't find it in the help book would that be what gui switch is ? thank you michael Link to comment Share on other sites More sharing options...
dabus Posted November 11, 2005 Share Posted November 11, 2005 (edited) Use the normal GuiCreate and modify like this: #include <GUIConstants.au3> $Gui1=GUICreate("My 1 GUI") ; will create a dialog box that when displayed is centered $Button1=GUICtrlCreateButton ( "Go" , 0, 0 ) GUISetState (@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg1 = GUIGetMsg() If $msg1 = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $msg1 = $Button1 Then AnotherGui () EndIf Wend Func AnotherGui () $Gui2=GUICreate("My 2 GUI") ; will create a dialog box that when displayed is centered $Button2=GUICtrlCreateButton ( "Stop" , 0, 0 ) GUISetState (@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg2 = GUIGetMsg() If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $msg2 = $Button2 Then GUIDelete ( $Gui2 ) ExitLoop EndIf Wend EndFunc Be sure to use variables once, that's all. And you could use OnEventMode to be more "responsive". #include <GUIConstants.au3> > Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Hello World", 200, 100) > GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") Exit EndFunc Edited November 11, 2005 by dabus Link to comment Share on other sites More sharing options...
Michael36 Posted November 11, 2005 Author Share Posted November 11, 2005 Use the normal GuiCreate and modify like this:#include <GUIConstants.au3> $Gui1=GUICreate("My 1 GUI"); will create a dialog box that when displayed is centered $Button1=GUICtrlCreateButton ( "Go" , 0, 0 ) GUISetState (@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg1 = GUIGetMsg() If $msg1 = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $msg1 = $Button1 Then AnotherGui () EndIf Wend Func AnotherGui () $Gui2=GUICreate("My 2 GUI"); will create a dialog box that when displayed is centered $Button2=GUICtrlCreateButton ( "Stop" , 0, 0 ) GUISetState (@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg2 = GUIGetMsg() If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $msg2 = $Button2 Then GUIDelete ( $Gui2 ) ExitLoop EndIf Wend EndFuncBe sure to use variables once, that's all.And you could use OnEventMode to be more "responsive".#include <GUIConstants.au3> > Opt("GUIOnEventMode", 1); Change to OnEvent mode $mainwindow = GUICreate("Hello World", 200, 100) > GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) While 1 Sleep(1000); Idle around WEnd Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") Exit EndFuncok thank you this is very helpfull thanks so much for the examples ! Link to comment Share on other sites More sharing options...
JSThePatriot Posted November 11, 2005 Share Posted November 11, 2005 ok thank you this is very helpfull thanks so much for the examples !I would recommend using the GUIGetMsg(1). It will allow you to poll both GUI's at the same time for events. Otherwise with the methods I have seen above you will only be able to perform on events happening in the last open GUI. It all really depends on what you are trying to do, and your preferences. The helpfile explains how to use the advanced message system to do what you are wanting done.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Michael36 Posted November 15, 2005 Author Share Posted November 15, 2005 I would recommend using the GUIGetMsg(1). It will allow you to poll both GUI's at the same time for events. Otherwise with the methods I have seen above you will only be able to perform on events happening in the last open GUI. It all really depends on what you are trying to do, and your preferences. The helpfile explains how to use the advanced message system to do what you are wanting done.JShi hmmm when i close gui 3 it shut downs the main gui is there a way to close just gui 3 ?thank youmichaelGuiSetState() While 1 $msg3 = GuiGetMsg() If $Msg3 = $GUI_EVENT_CLOSE Then ExitLoop Link to comment Share on other sites More sharing options...
JSThePatriot Posted November 15, 2005 Share Posted November 15, 2005 hi hmmm when i close gui 3 it shut downs the main gui is there a way to close just gui 3 ?thank youmichaelGuiSetState() While 1 $msg3 = GuiGetMsg() If $Msg3 = $GUI_EVENT_CLOSE Then ExitLoopWell you need to look into working with GUI's like I mentioned above. Using the advanced option of GUIGetMsg() I know it is alot of hassle to re-write some of the code to accomodate it, but it is fully worth it.I will give an example soon. I am currently working on a script that has two GUI's and having no issues. I can close either one.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Michael36 Posted November 23, 2005 Author Share Posted November 23, 2005 Well you need to look into working with GUI's like I mentioned above. Using the advanced option of GUIGetMsg() I know it is alot of hassle to re-write some of the code to accomodate it, but it is fully worth it.I will give an example soon. I am currently working on a script that has two GUI's and having no issues. I can close either one.JSok thank you will be looking fwd to it Link to comment Share on other sites More sharing options...
Zithen Posted November 23, 2005 Share Posted November 23, 2005 here is the example that i templet my gui interfaces from that open more windows. hope it helps or what u are looking for expandcollapse popup#include <GuiConstants.au3> #include <Process.au3> Dim $intWindow Dim $secwindow DisplayGUI() Func DisplayGUI() Local $intWindow Local $intBtnExit Local $intMsg Local $intBtnDelete $intWindow = GUICreate("script", 500, 180) $intBtnsec = GUICtrlCreateButton("Second", 100, 130, 70, 30) $intBtnExit = GUICtrlCreateButton("Exit", 385, 130, 70, 30) GUISetState() While 1 $intMsg = GUIGetMsg() Select Case $intMsg = $GUI_EVENT_CLOSE Or $intMsg = $intBtnExit ExitLoop Case $intMsg = $intBtnsec sectest() EndSelect WEnd GUIDelete($intWindow) EndFunc Func sectest() $delwindow = GUICreate("Delete Printers", 400, 230, -1, -1, BitOR($WS_POPUP,$WS_CAPTION), -1, $intWindow) $DelBtnExit = GUICtrlCreateButton("Exit", 305, 190, 70, 30) GUISetState(@SW_SHOW) While 2 $msg2 = GUIGetMsg() Select Case $msg2 = $DelBtnExit GUIDelete($delwindow) Return EndSelect WEnd Exit EndFunc Link to comment Share on other sites More sharing options...
Michael36 Posted November 23, 2005 Author Share Posted November 23, 2005 here is the example that i templet my gui interfaces from that open more windows. hope it helps or what u are looking for expandcollapse popup#include <GuiConstants.au3> #include <Process.au3> Dim $intWindow Dim $secwindow DisplayGUI() Func DisplayGUI() Local $intWindow Local $intBtnExit Local $intMsg Local $intBtnDelete $intWindow = GUICreate("script", 500, 180) $intBtnsec = GUICtrlCreateButton("Second", 100, 130, 70, 30) $intBtnExit = GUICtrlCreateButton("Exit", 385, 130, 70, 30) GUISetState() While 1 $intMsg = GUIGetMsg() Select Case $intMsg = $GUI_EVENT_CLOSE Or $intMsg = $intBtnExit ExitLoop Case $intMsg = $intBtnsec sectest() EndSelect WEnd GUIDelete($intWindow) EndFunc Func sectest() $delwindow = GUICreate("Delete Printers", 400, 230, -1, -1, BitOR($WS_POPUP,$WS_CAPTION), -1, $intWindow) $DelBtnExit = GUICtrlCreateButton("Exit", 305, 190, 70, 30) GUISetState(@SW_SHOW) While 2 $msg2 = GUIGetMsg() Select Case $msg2 = $DelBtnExit GUIDelete($delwindow) Return EndSelect WEnd Exit EndFunc thank you Zithen that is just what i was looking for 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