AndrewG Posted December 21, 2008 Share Posted December 21, 2008 Hello Scripters I'm new to AutoIt, but I have a background in PHP and Javascript, and some time with VisualBasic 4. I'm trying to exit out of a conditional without exiting the gui. I'm testing for text in an input, if no text is found throw a message box and stop. Do not exit GUI. If I use the Exit keyword the GUI exits completely. I do not want this to happen. How do I do this in AutoIt? I have searched the AutoIt Help file, and this forum, with no luck. Please help. My Script expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) AutoItSetOption("MustDeclareVars", 1) ;Declare variables Global $mainForm Global $menuFile, $menuFileItemExit Global $txtInput, $cmdAdd ;Create main window $mainForm = GUICreate("Add Text To File", 400, 150, (@DeskTopWidth - 400)/2, (@DeskTopHeight - 150)/2) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;Create File menu and items $menuFile = GUICtrlCreateMenu("&File") $menuFileItemExit = GUICtrlCreateMenuItem("E&xit", $menuFile) GUICtrlSetOnEvent($menuFileItemExit, "CLOSEClicked") ;Create input text box $txtInput = GUICtrlCreateInput("",20, 40, 300, 20) $cmdAdd = GUICtrlCreateButton("Add", 325, 40, 40, 20) ;Create add Button GUICtrlSetOnEvent($cmdAdd, "AddText") ;Show GUI GUISetState(@SW_SHOW) while 1 Sleep(1000) WEnd ;Add Text To File Func func AddText() Local $NL, $txt, $handle, $write, $close $NL = @CRLF;Carraige return and line feed $txt = GUICtrlRead($txtInput) If $txt = "" Then MsgBox(48, "No Text", "There isn't any text to enter!") Exit EndIf $handle = FileOpen("text.txt", 1) $write = FileWrite($handle, $txt & $NL) $close = FileClose($handle) GUICtrlSetData($txtInput, "") MsgBox(0, "Added Text", $txt) EndFunc ;Exit GUI Func CLOSEClicked() Exit EndFunc Link to comment Share on other sites More sharing options...
Zedna Posted December 21, 2008 Share Posted December 21, 2008 Return quits current function: If $txt = "" Then MsgBox(48, "No Text", "There isn't any text to enter!") Return EndIf Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
AndrewG Posted December 21, 2008 Author Share Posted December 21, 2008 Return quits current function: If $txt = "" Then MsgBox(48, "No Text", "There isn't any text to enter!") Return EndIf Thanks. I new it was simple. I just realized I could have used an if else statement.... 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