mIRC Home    About    Download    Register    News    Help

Print Thread
Halting/Suspending the ON EXIT event #179242 19/06/07 04:43 PM
Joined: Apr 2003
Posts: 342
M
MeStinkBAD Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
When you /exit the program by typing /exit or closing the main application window, etc, it trigger's the on exit event (well i assume) but you can't control the exit process.

Neither of these work.

Code:
on ^*:exit: {
  halt
}

on *:exit: {
  while 1 { }
}


Now I really don't wanna prevent the program from exiting, but I would like to do some processing, which may output text to a window or open a dialog or something. I should be able to do this. Even halt termination if I wished.


Beware of MeStinkBAD! He knows more than he actually does!
Re: Halting/Suspending the ON EXIT event [Re: MeStinkBAD] #179243 19/06/07 04:52 PM
Joined: Apr 2004
Posts: 862
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 862
You should be able to open a modal dialog (i.e. created with $dialog()) from the "on exit" event. Even if that dialog displays only "Please wait" to the user, you can do other processing while it's open. Only when the dialog is closed (and the $dialog() call therefore returns) will mIRC actually exit. Similar hack'ish solutions include $input and blocking com object calls (like the various /sleep snippets out there).

I'm not sure it should be possible to actually prevent mIRC from closing at all..


Saturn, QuakeNet staff
Re: Halting/Suspending the ON EXIT event [Re: Sat] #179244 19/06/07 05:17 PM
Joined: Apr 2003
Posts: 342
M
MeStinkBAD Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Originally Posted By: Sat
You should be able to open a modal dialog (i.e. created with $dialog()) from the "on exit" event. Even if that dialog displays only "Please wait" to the user, you can do other processing while it's open. Only when the dialog is closed (and the $dialog() call therefore returns) will mIRC actually exit. Similar hack'ish solutions include $input and blocking com object calls (like the various /sleep snippets out there).


Well I haven't tried opening a modal dialog. But I have a /sleep call and it does not prevent mIRC from closing the windows. Honestly though... you should not need a "hack'ish" solution for this.

Quote:
I'm not sure it should be possible to actually prevent mIRC from closing at all..


You can't prevent someone from forcing a program to quit. Either thru the task manager or some other approach. Indeed... you can create an unbreakable loop that requires a force quit at present. And it also renders the program useless. Interupting the standard exit process thru the on exit event should be possible, since I can see many uses where it would be beneficial.

*NOTE* $input(Hello) does pause the exit process until closed. So I assume using a modal dialog would work. Still once the modal dialog is closed, the application would quit. And while open mIRC is unusable.

One interesting question halting this brings up. Breaking the operation (with cntrl-break) could either resume exiting, or stop the event without quiting. Hmmm...

Last edited by MeStinkBAD; 19/06/07 05:26 PM.

Beware of MeStinkBAD! He knows more than he actually does!
Re: Halting/Suspending the ON EXIT event [Re: MeStinkBAD] #179249 19/06/07 05:43 PM
Joined: Apr 2004
Posts: 862
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 862
A COM-based /sleep alias does work for this purpose just as well. I just tried, to make sure.

Originally Posted By: MeStinkBAD
Interupting the standard exit process thru the on exit event should be possible, since I can see many uses where it would be beneficial.

It would probably help if you mentioned a few of them smile


Saturn, QuakeNet staff
Re: Halting/Suspending the ON EXIT event [Re: MeStinkBAD] #179283 20/06/07 04:18 AM
Joined: Jul 2003
Posts: 655
Om3n Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
The on EXIT event was added for the purpose of processing final tasks prior to the problem closing (such as saving settings or whatever). The very idea of being able to completely halt this event from following through with the programs closure is obsurd. (the same could be said for on UNLOAD, im not sure how this behaves myself)

If you use the on EXIT event to halt the programs closure, then the even should not have triggered should it? So it has potentially performed tasks at a time when it should not have done so. I hope you see the point im making.

Not sure how mirc handles a scripted /exit alias, but maybe that specifically could be halted to prevent it from triggering the exit.


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
Re: Halting/Suspending the ON EXIT event [Re: MeStinkBAD] #179315 21/06/07 01:56 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
If a program/script prevented me from exiting the program, I'd terminate it immediately and uninstall the program/script. If I click the X on a window, I expect it to close (perhaps after a save/don't save dialog).

-genius_at_work

Re: Halting/Suspending the ON EXIT event [Re: Om3n] #179415 22/06/07 06:30 PM
Joined: Dec 2002
Posts: 580
N
NaquadaServ Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Originally Posted By: Om3n
Not sure how mirc handles a scripted /exit alias, but maybe that specifically could be halted to prevent it from triggering the exit.


Like all mIRC's commands, /exit can be changed as well, preventing the actual exit if desired.

Code:
alias exit {
  if ($input(Are you sure you want to exit?, yvq, Exit mIRC) == $yes) exit
}


I have also wanted a "pre-exit event" that is called at the very start of the exit process (that stops on haltdef) without having to realias exit (because what if some other script also realiases exit?).

Edit: This code only works if trying to prevent /exit from taking place.

Code:
alias exit {
  exit
  ; Once called, /exit doesn't return
  ; This point is never reached
}


Edit2: $com sleep seems the best option for delaying an actual exit, as long as it doesn't freeze the GUI.

Originally Posted By: genius_at_work
If a program/script prevented me from exiting the program, I'd terminate it immediately and uninstall the program/script.


I think it's more for checking error messages that appear on the exit event... wink

Last edited by NaquadaServ; 22/06/07 06:51 PM.

NaquadaBomb
www.mirc-dll.com