eri Posted February 20, 2010 Share Posted February 20, 2010 expandcollapse popup#include <GUIConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> one() Func one() $Window = GUICreate("Gui One *", 230, 56) $one = GUICtrlCreateButton("One", 10, 16, 60, 25, 0) $two = GUICtrlCreateButton("Two", 80, 16, 60, 25, 0) $about = GUICtrlCreateButton("About", 150, 16, 70, 25, 0) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $one GUIDelete() one() Case $two GUIDelete() two() Case $about about() EndSwitch WEnd EndFunc Func two() $Window = GUICreate("Gui Two **", 230, 56) $one = GUICtrlCreateButton("One", 10, 16, 60, 25, 0) $two = GUICtrlCreateButton("Two", 80, 16, 60, 25, 0) $about = GUICtrlCreateButton("About", 150, 16, 70, 25, 0) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $one GUIDelete() one() Case $two GUIDelete() two() Case $about about() EndSwitch WEnd EndFunc Func about() Local $Gui, $OptionsBtn, $Label1, $Icon1, $Label2 , $Label3, $hGUI, $label, $x $Gui = GUICreate("About GUI ***", 245, 153) GUISetBkColor(0x3399FF) $OptionsBtn = GUICtrlCreateButton("Exit", 20, 125, 83, 25) GUICtrlSetFont(-1, 12, 400, 0, "Gloucester MT Extra Condensed") $Label1 = GUICtrlCreateLabel("AutoIt", 125, 128, 104, 25) GUICtrlSetFont(-1, 12, 800, 4, "Pristina") GUICtrlSetColor(-1, 0xFF0000) $Icon = GUICtrlCreateIcon("Icon.ico", -1, 10, 7, 40, 40) GUISetState(@SW_SHOW) $hGUI =GUICreate("txt", 235, 70, 5, 50, BitOR($WS_MINIMIZEBOX, $WS_CHILD),-1,$Gui) $label = GUICtrlCreateLabel(" My Sample AutoIt"& @CRLF _ &" Create Animation Text", 5, 10, 230, 230,$SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Comic Sans MS") GUISetState(@SW_SHOW) While 1 For $x = 1 To 300 GUICtrlSetPos($label, 0, 70-$x) Sleep(30) $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE, $OptionsBtn GUIDelete($Gui) ExitLoop EndSwitch Next WEnd EndFunc Click one, two Button OK.. After Click About Button.. One and Two Button Not Working And Can`t Close Gui.. Please Correct It`s For Me.. Link to comment Share on other sites More sharing options...
martin Posted February 20, 2010 Share Posted February 20, 2010 expandcollapse popup#include <GUIConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> one() Func one() $Window = GUICreate("Gui One *", 230, 56) $one = GUICtrlCreateButton("One", 10, 16, 60, 25, 0) $two = GUICtrlCreateButton("Two", 80, 16, 60, 25, 0) $about = GUICtrlCreateButton("About", 150, 16, 70, 25, 0) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $one GUIDelete() one() Case $two GUIDelete() two() Case $about about() EndSwitch WEnd EndFunc Func two() $Window = GUICreate("Gui Two **", 230, 56) $one = GUICtrlCreateButton("One", 10, 16, 60, 25, 0) $two = GUICtrlCreateButton("Two", 80, 16, 60, 25, 0) $about = GUICtrlCreateButton("About", 150, 16, 70, 25, 0) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $one GUIDelete() one() Case $two GUIDelete() two() Case $about about() EndSwitch WEnd EndFunc Func about() Local $Gui, $OptionsBtn, $Label1, $Icon1, $Label2 , $Label3, $hGUI, $label, $x $Gui = GUICreate("About GUI ***", 245, 153) GUISetBkColor(0x3399FF) $OptionsBtn = GUICtrlCreateButton("Exit", 20, 125, 83, 25) GUICtrlSetFont(-1, 12, 400, 0, "Gloucester MT Extra Condensed") $Label1 = GUICtrlCreateLabel("AutoIt", 125, 128, 104, 25) GUICtrlSetFont(-1, 12, 800, 4, "Pristina") GUICtrlSetColor(-1, 0xFF0000) $Icon = GUICtrlCreateIcon("Icon.ico", -1, 10, 7, 40, 40) GUISetState(@SW_SHOW) $hGUI =GUICreate("txt", 235, 70, 5, 50, BitOR($WS_MINIMIZEBOX, $WS_CHILD),-1,$Gui) $label = GUICtrlCreateLabel(" My Sample AutoIt"& @CRLF _ &" Create Animation Text", 5, 10, 230, 230,$SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Comic Sans MS") GUISetState(@SW_SHOW) While 1 For $x = 1 To 300 GUICtrlSetPos($label, 0, 70-$x) Sleep(30) $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE, $OptionsBtn GUIDelete($Gui) ExitLoop EndSwitch Next WEnd EndFunc Click one, two Button OK.. After Click About Button.. One and Two Button Not Working And Can`t Close Gui.. Please Correct It`s For Me.. There is no way to get oout of your about function. The exitloop only exits the for/next loop so you could replace exitloop with return. You have some other aspects which need attention though. Your script is continually creating and destroying controls without needing to, and the functions call them selves with no returns so you will eventually find it will crash as you use up more and more memory. Sometimes it is useful to have a function call itself but without a good reason I advise that you don't do it. I assume you are new to programming and if so what you have produced is an excellent start but here are some tips. Try to have one main loop. From that call call functions which execute and return. Do not duplicate code if it can be avoided. If you have the same code in 3 places and you decide to make a change or correction then you have to do it 3 times. Do not destroy controls if they will need to be recreated later; it would be better to hide them or disable them. Here is something like what I would normally do expandcollapse popup#include <GUIConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> one() Func one() $Window = GUICreate("Gui One *", 230, 56) $one = GUICtrlCreateButton("One", 10, 16, 60, 25, 0) $two = GUICtrlCreateButton("Two", 80, 16, 60, 25, 0) $about = GUICtrlCreateButton("About", 150, 16, 70, 25, 0) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $one setstars($Window, "one star *") Case $two setstars($Window, "two stars **") Case $about about() EndSwitch WEnd EndFunc ;==>one Func setstars($hWind, $sTitle) WinSetTitle($hWind, "", $sTitle) EndFunc ;==>setstars Func about() Local $Gui, $OptionsBtn, $Label1, $Icon1, $Label2, $Label3, $hGUI, $label, $x $Gui = GUICreate("About GUI ***", 245, 153) GUISetBkColor(0x3399FF) $OptionsBtn = GUICtrlCreateButton("Exit", 20, 125, 83, 25) GUICtrlSetFont(-1, 12, 400, 0, "Gloucester MT Extra Condensed") $Label1 = GUICtrlCreateLabel("AutoIt", 125, 128, 104, 25) GUICtrlSetFont(-1, 12, 800, 4, "Pristina") GUICtrlSetColor(-1, 0xFF0000) $Icon = GUICtrlCreateIcon("Icon.ico", -1, 10, 7, 40, 40) GUISetState(@SW_SHOW) $hGUI = GUICreate("txt", 235, 70, 5, 50, BitOR($WS_MINIMIZEBOX, $WS_CHILD), -1, $Gui) $label = GUICtrlCreateLabel(" My Sample AutoIt" & @CRLF _ & " Create Animation Text", 5, 10, 230, 230, $SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Comic Sans MS") GUISetState(@SW_SHOW) While 1 For $x = 1 To 300 GUICtrlSetPos($label, 0, 70 - $x) Sleep(30) $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $OptionsBtn GUIDelete($Gui) Return;ExitLoop EndSwitch Next WEnd ConsoleWrite("leave about" & @CRLF) EndFunc ;==>about Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
eri Posted February 20, 2010 Author Share Posted February 20, 2010 yes that's right I'm very new in programming and AutoIt is the first programming language I know. That is why I ask many questions in this forum because I wanted to know about programming. Thank you so much for Solution.. 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