When $input is used in the APPACTIVE event, then returning to mIRC while there is an open $input dialog triggers 4 extra APPACTIVE events.
Thanks for your bug report. The APPACTIVE event is triggered by Windows. It is notifying mIRC that it has been either activated or de-activated. That is its purpose. There is no way to change how it works as it is quite literally Windows that is sending this message. To complicate matters, you are using a $input() that changes the active focus in the event that is meant to report the changing of active focus :-) You need to find a way around this in your script.