Jump to content
Sign in to follow this  
Cambo

Make the X (top right hand corner) button close my compiled script?!

Recommended Posts

This is a really simple question and I feel kind of stupid for having to ask it, but is there a way to map the X button? (default windows close button)

Right now when I run my compiled script, the big red X does absolutely nothing. I've browsed through the GUI documentation but don't see anything. And actually I need it to do a little more than just close the program. Right now F6 closes my script, and it does a few other things on the closing.

On exit right now it does:

writeLog("Quit program. Deleted temp files")

FileClose($Name)

FileClose($file)

Is there a way to map the big shiny red X to do that?

Share this post


Link to post
Share on other sites

While 1

    $msg = GUIGetMsg()
    Select
        
        Case $msg = $Something
        ;;;;something happens
        
        Case $msg = $GUI_EVENT_CLOSE
            writeLog("Quit program. Deleted temp files")
            FileClose($Name)
            FileClose($file)
            Exit
    EndSelect
WendoÝ÷ Ù«­¢+Ù]¡¥±Ä(ÀÌØíµÍôU%Ñ5Í ¤((%ÀÌØíµÍôÀÌØíU%}Y9Q}
1=MQ¡¸(ÝÉ¥Ñ1½ ÅÕ½ÐíEÕ¥ÐÁɽɴ¸±ÑѵÀ¥±ÌÅÕ½Ðì¤(¥±
±½Í ÀÌØí9µ¤(¥±
±½Í ÀÌØí¥±¤(á¥Ð(¹%)]¹

Share this post


Link to post
Share on other sites

I prefer GuiOnEventMode, because your script can get work done and is not trapped in the GuiGetMsg() loop:

#include <GuiConstants.au3>

Opt("GuiOnEventMode", 1)

$hGUI = GUICreate("Test", 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUICtrlCreateLabel("Click the red X, I dare you!", 10, 10, 280, 20, $SS_CENTER)
GUICtrlCreateButton("TEST", 100, 150, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUISetState()

While 1
    ;
    ; you can get work done here
    ; while waiting for events
    ;
    Sleep(20)
WEnd

Func _ButtonHit()
    MsgBox(16, "Stop Clicking Me!", "Who told you to mess with buttons?!  Click the red X!")
EndFunc   ;==>_ButtonHit

Func _Quit()
    ; Clean up stuff:
    ;   writeLog("Quit program. Deleted temp files")
    ;   FileClose($Name)
    ;   FileClose($file)
    Exit
EndFunc   ;==>_Quit

:)


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

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  

×
×
  • Create New...