Jeroenvdpol Posted October 18, 2012 Share Posted October 18, 2012 Hello Guys, I am kind of new to Auto-it, also not a experienced scripter. Here's my issue, probably is simple one to solve. I created i Gui with a button that performs a action, the action is to create a input box. When i cancel the inputbox my script keeps running. I tried to exit the script after i press the cancel button, but offstead of canceling the script i shut down the gui. Sorry for my bad Englisch i'am Dutch. I have made a script something like this: ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Gui = GUICtrlCreateLabel("Gui", 72, 40, 20, 17) $Button1 = GUICtrlCreateButton("Button1", 56, 112, 161, 65) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $VAR1 = InputBox("Hallo","Proberen") If $VAR1 = "" Then Exit #### When I remove this one the scripts continue.. Run ("notepad.exe") WinWaitActive ("Untitled - Notepad") Send ($VAR1) EndSwitch WEnd How do i solve this? Link to comment Share on other sites More sharing options...
JohnOne Posted October 18, 2012 Share Posted October 18, 2012 I'm not sure what you need.replaceIf $VAR1 = "" Then ExitwithIf @error Then Exit AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
FireFox Posted October 18, 2012 Share Posted October 18, 2012 Hi, Welcome to the autoit forum Change Exit to ContinueCase, it will skip to the next switch case, and as far as there is none, it will exit the switch. You can also use functions : ... Case $Button1 _toto() EndSwitch WEnd Func _toto() $VAR1 = InputBox("Hallo", "Proberen") If $VAR1 = "" Then Return ;Exit Func Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send($VAR1) EndFunc ;==>_toto Br, FireFox. Link to comment Share on other sites More sharing options...
Jeroenvdpol Posted October 18, 2012 Author Share Posted October 18, 2012 I'm not sure what you need.replaceIf $VAR1 = "" Then ExitwithIf @error Then ExitThanks, but not what i'am looking for.I dont want to exit te program, i want to stop the script and return to the gui form.Like a normal cancel, whit no further script attached. Link to comment Share on other sites More sharing options...
FireFox Posted October 18, 2012 Share Posted October 18, 2012 Thanks, but not what i'am looking for.I dont want to exit te program, i want to stop the script and return to the gui form.Like a normal cancel, whit no further script attached.So my reply is invisible, great... Link to comment Share on other sites More sharing options...
JohnOne Posted October 18, 2012 Share Posted October 18, 2012 Do $VAR1 = InputBox("Hallo","Proberen")Until Not @error AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Jeroenvdpol Posted October 18, 2012 Author Share Posted October 18, 2012 (edited) Hi, Welcome to the autoit forum Change Exit to ContinueCase, it will skip to the next switch case, and as far as there is none, it will exit the switch. You can also use functions : ... Case $Button1 _toto() EndSwitch WEnd Func _toto() $VAR1 = InputBox("Hallo", "Proberen") If $VAR1 = "" Then Return ;Exit Func Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send($VAR1) EndFunc ;==>_toto Br, FireFox. Thanks, this is it The function method works for me. The ContinueCase starts a case witch only must be started by clicking the button. #So my reply is invisible, great... (Didn't refresh browser ) Edited October 18, 2012 by Jeroenvdpol Link to comment Share on other sites More sharing options...
FireFox Posted October 18, 2012 Share Posted October 18, 2012 (edited) The function method works for me. The ContinueCase starts a case witch only must be started by clicking the button. You can swap the button Case with the inputbox Case, OR add an empty Case after this last : ... Case $Button1 $VAR1 = InputBox("Hallo", "Proberen") If $VAR1 = "" Then ContinueCase ... Case "EMPTY" ;do nothing Case $Button2 ... (Didn't refresh browser ) hehe. np Br, FireFox. Edited October 18, 2012 by FireFox 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