Jump to content
Sign in to follow this  
Jeroenvdpol

Exit to gui instead of Exiting GUI (Beginners Question)

Recommended Posts

Jeroenvdpol

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?

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Jeroenvdpol

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.

Share this post


Link to post
Share on other sites
FireFox

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:

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Jeroenvdpol

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

Share this post


Link to post
Share on other sites
FireFox

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  

×