Jump to content
Sign in to follow this  
Noob

How to close my GUI without exiting my script

Recommended Posts

Noob

Hi Guys,

I've spent the better part of today trying to figure out how to close my GUI without exiting my script. I read the help, I searched the Forum, but I'm just too new to this to get to the bottom of this myself.

Here is the simplification of my code. I have a script that does a variety of things, one of which should be a function which will create a GUI. When I click the close button in the top right corner of the GUI, I want the GUI to close, but I don't want the script to exit.

Any help would be greatly appreciated.

HotKeySet("{F2}", "my_gui")

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    Sleep(100) 
WEnd

Func my_gui()
GUICreate("My 1st GUI :-)")
GUISetState ()
EndFunc

Share this post


Link to post
Share on other sites
strate

GUISetState (@SW_HIDE)

??


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites
Noob

GUISetState (@SW_HIDE)

??

It works!

LOL, I'm an idiot :-)

Thanks much!

Share this post


Link to post
Share on other sites
Helge

Note that if you press F2 multiple times you will get multiple GUIs. I modified the script a bit, so that if press close

the GUI it will be hidden, while you can make it visible again by pressing F2. I also made it impossible to press F2

while the GUI is visible, avoiding having multiple GUIs at the same time. Kind of guessing what you want, but it

might be of some help.

GUICreate("My 1st GUI :-)") ; Create it once in the beginning without showing it
HotKeySet("{F2}", "my_gui")

While 1
    $msg = GUIGetMsg()
    
    If $msg = -3 Then
        GUISetState(@SW_HIDE)       ; Hide GUI
        HotKeySet("{F2}", "my_gui") ; Enable hotkey
    EndIf
WEnd

Func my_gui()
    GUISetState(@SW_SHOW)   ; Show GUI
    HotKeySet("{F2}")       ; Disable hotkey
EndFunc

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.