I added the check for the modal dialog by checking if the main window is disabled.  As you noted, this won't catch the JS "modal" dialogs, like the About box.  However, as those aren't really modal, the selected file still gets opened anyway.  Consequently, I didn't bother iterating the child windows to watch for these.  It still seems to work as expected.  However, if you're really bothered by this, I can add it.