Jump to content

Exit to gui instead of Exiting GUI (Beginners Question)


Recommended Posts

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

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

I'm not sure what you need.

replace

If $VAR1 = "" Then Exit

with

If @error Then Exit

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.

Link to comment
Share on other sites

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... :guitar:
Link to comment
Share on other sites

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 :thumbsup:

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... :guitar:

(Didn't refresh browser ;) )

Edited by Jeroenvdpol
Link to comment
Share on other sites

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 by FireFox
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...