mIRC Homepage
Posted By: MeStinkBAD Halting/Suspending the ON EXIT event - 19/06/07 04:43 PM
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.
Posted By: Sat Re: Halting/Suspending the ON EXIT event - 19/06/07 04:52 PM
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..
Posted By: MeStinkBAD Re: Halting/Suspending the ON EXIT event - 19/06/07 05:17 PM
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...
Posted By: Sat Re: Halting/Suspending the ON EXIT event - 19/06/07 05:43 PM
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
Posted By: Om3n Re: Halting/Suspending the ON EXIT event - 20/06/07 04:18 AM
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.
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
Posted By: NaquadaServ Re: Halting/Suspending the ON EXIT event - 22/06/07 06:30 PM
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
© mIRC Discussion Forums