Jump to content
Sign in to follow this  
lolp1

How to do something, before a user exits the program

Recommended Posts

lolp1

Hello,

I was not sure, how I could do something before a users attempts to close a program. For example if they tried to close the program, MsgBox("64","test","Do you really want to exit the program?")

Any help is appreciated.

Share this post


Link to post
Share on other sites
Valuater

#include <GUIConstants.au3>

Opt("OnExitFunc", "endscript")

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Func endscript()
    MsgBox(0,"","after last statement " & @EXITMETHOD)
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
SmOke_N

@lop... Quite a "novice" question for someone that has been here so long?

#include <GUIConstants.au3>

Opt("OnExitFunc", "endscript")

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Func endscript()
    MsgBox(0,"","after last statement " & @EXITMETHOD)
EndFunc
?

Edit:

Had to fix to whom I was talking to/about there.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
lolp1

@lop... Quite a "novice" question for someone that has been here so long?

Or

Func OnAutoItExit()
   ;Etc
EndFunc
?

Edit:

Had to fix to whom I was talking to/about there.

Well I've never had to do this, and I looked all over the help files and searched it, and could not find any information. How did you expect me to figure it out, magic?

Share this post


Link to post
Share on other sites
SmOke_N

Well I've never had to do this, and I looked all over the help files and searched it, and could not find any information. How did you expect me to figure it out, magic?

No... Common sense would have worked for me :) ... You know, Autoit's help file "search" option or even ... the forums search option(s).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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  

×