Sign in to follow this  
Followers 0
Testy

Window will not close with the X

18 posts in this topic

Hi all,

The script that I created, will not close the window with the X. I had to create an exit button.

Is there a quick fix? Still learning.

I love my script. I'm just getting heckled by people...

Thank you,

Share this post


Link to post
Share on other sites



When you include GUIConstants, make sure in your loop you have: $GUI_EVENT_CLOSE, this means the X was pressed.

Share this post


Link to post
Share on other sites

or you can always do this

Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")

Func _exit()
MsgBox(0, "", "Goodbye")
Exit
EndFunc

Share this post


Link to post
Share on other sites

Swift gave you a good answer, but I love a quickie demo:

#include <GuiConstants.au3>

$hGUI = GUICreate("Test", 200, 200)
$Button = GUICtrlCreateButton("OK", 20, 20, 160, 160)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            MsgBox(64, "OK", "OK")
    EndSwitch
WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Good little example PSalty :) . I could of done that :)

Share this post


Link to post
Share on other sites

I must have something going on in my script, or do not have the proper placement for the examples posted. None of them allowed the x buttom on the window to work/close it.

Share this post


Link to post
Share on other sites

Show some code!

Share this post


Link to post
Share on other sites

I must have something going on in my script, or do not have the proper placement for the examples posted. None of them allowed the x buttom on the window to work/close it.

even mine?

:)

Share this post


Link to post
Share on other sites

even mine?

:)

The only problem with yours was it is incomplete. I personally prefer event mode for my GUIs, but message mode is easier to start out with.

#include <GuiConstants.au3>

Opt("GuiOnEventMode", 1)

$hGUI = GUICreate("Test", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$Button = GUICtrlCreateButton("OK", 20, 20, 160, 160)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func _ButtonHit()
    MsgBox(64, "OK", "OK")
EndFunc

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

The only problem with yours was it is incomplete. I personally prefer event mode for my GUIs, but message mode is easier to start out with.

#include <GuiConstants.au3>

Opt("GuiOnEventMode", 1)

$hGUI = GUICreate("Test", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$Button = GUICtrlCreateButton("OK", 20, 20, 160, 160)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func _ButtonHit()
    MsgBox(64, "OK", "OK")
EndFunc

:)

incomplete eh?

just because i posted an example instead of full code?

:)

Share this post


Link to post
Share on other sites

incomplete eh?

just because i posted an example instead of full code?

:)

Just a personal thang... I prefer fully self-contained demo scripts that can be run as posted. There was nothing wrong with your example, I just prefer a running demo. Some kind of OCD problem I have. :)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Just a personal thang... I prefer fully self-contained demo scripts that can be run as posted. There was nothing wrong with your example, I just prefer a running demo. Some kind of OCD problem I have. :)

If answers are which you seek.

Seek Here.

Edited by Swift

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Just a personal thang... I prefer fully self-contained demo scripts that can be run as posted. There was nothing wrong with your example, I just prefer a running demo. Some kind of OCD problem I have. :)

ah i see.

is good

they can run the example, and then they grasp concept of how it works.

:)

Edit:

If answers are which you seek.

Seek Here...............

OH MY GOD!

i found every answer i need there

:party:

Edited by Tomb616

Share this post


Link to post
Share on other sites

If answers are which you seek.

Seek Here.

No, no! They're HERE!

A few hours of zen-like meditation on that site will reveal all...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Show some code!

Thank you, I got it.

Edited by Testy

Share this post


Link to post
Share on other sites

OK Here goes... You have been warned.

You were not paying attention to the answers you already got. All you needed was this:
While 1

    ; ...

        Case $Button7r7
            Run("C:\Abel_Thin\jade.exe appServer=44.55.61.16 appServerPort=" & $port & "")
            login()

        Case $GUI_EVENT_CLOSE
            _Exit()

        Case $Exit
            _Exit()

    EndSwitch
WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

that is the most buttons i have ever seen in my life.

Share this post


Link to post
Share on other sites

You were not paying attention to the answers you already got. All you needed was this:

While 1

    ; ...

        Case $Button7r7
            Run("C:\Abel_Thin\jade.exe appServer=44.55.61.16 appServerPort=" & $port & "")
            login()

        Case $GUI_EVENT_CLOSE
            _Exit()

        Case $Exit
            _Exit()

    EndSwitch
WEnd

:)

I got it, your reply jogged it, and I got the context, it didn't work at first then it clicked. Than you all.

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  
Followers 0