Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Om de ûnderfining foar jo te ferbetterjen is tydlik de funksjonaliteit dan dizze website troch ûnderhâldswurk beheind. Wannear in artikel jo probleem net oplost en jo in fraach stelle wolle, kin ús stipemienskip jo helpe yn @FirefoxSupport op Twitter en /r/firefox op Reddit.

Sykje yn Support

Mij stipescams. Wy sille jo nea freegje in telefoannûmer te beljen, der in sms nei ta te stjoeren of persoanlike gegevens te dielen. Meld fertochte aktiviteit mei de opsje ‘Misbrûk melde’.

Mear ynfo

Dizze konversaasje is argivearre. Stel in nije fraach as jo help nedich hawwe.

PowerShell to Confirm or Cancel popup box to close multiple tabs?

  • 6 antwurd
  • 1 hat dit probleem
  • 1 werjefte
  • Lêste antwurd fan SAI157

more options

Powershell runs and and closes (using .CloseMainWindow()) Firefox window. If there are multiple tabs, 'Confirm close' message will pop up to let the user decide.

If there is one window with one or multiple tabs, the script works fine. If there are multiple windows with multiple tabs opened, .CloseMainWindow() only closes the top window. So, I ran a loop to check if Firefox is running and if it is, the process will be closed and 'Confirm close' will be shown, The script automatically, Send a key to confirm close tabs after 15 seconds,

The problem is that if the user click cancel, the loop keeps prompting the 'Confirm close' pop up until the process is closed.

Is there a way to check which button 'Close tabs' OR 'cancel' is clicked so upon hitting 'cancel', user can get out of the loop.

I don't want to use stop-process as it will show an error when Firefox is launched next time. I want to close it gracefully.

Or is there any other way to achieve this?

Thank you.

Powershell runs and and closes (using .CloseMainWindow()) Firefox window. If there are multiple tabs, 'Confirm close' message will pop up to let the user decide. If there is one window with one or multiple tabs, the script works fine. If there are multiple windows with multiple tabs opened, .CloseMainWindow() only closes the top window. So, I ran a loop to check if Firefox is running and if it is, the process will be closed and 'Confirm close' will be shown, The script automatically, Send a key to confirm close tabs after 15 seconds, The problem is that if the user click cancel, the loop keeps prompting the 'Confirm close' pop up until the process is closed. Is there a way to check which button 'Close tabs' OR 'cancel' is clicked so upon hitting 'cancel', user can get out of the loop. I don't want to use stop-process as it will show an error when Firefox is launched next time. I want to close it gracefully. Or is there any other way to achieve this? Thank you.

Bewurke troch SAI157 op

Alle antwurden (6)

more options

Doesn't the user know you are running this script so they can avoid interfering with it? If not, they will know soon enough based on the problem it creates...

more options

I suppose I should say more generally that what Powershell can and can't detect is beyond the scope of this forum, and you could check with Technet or another site where regular users of the tool hang out.

more options
In reply to jscher2000

They do, but if they would like to cancel it momentarily, they can. Script will run after sometime again. Eventually, they would have to close to.

Bewurke troch SAI157 op

more options
In reply to jscher2000

You're right. But, what I am trying to find out is the name of the event handlers, so I can check if user clicks confirm or cancel, if possible.

Bewurke troch SAI157 op

more options

It would be somewhere in the source code repository, but the closest I can get you this section:

https://dxr.mozilla.org/mozilla-central/source/browser/components/nsBrowserGlue.js#1229

I haven't tried to find the form to see the actual event handlers attached to it. Hopefully you have time to hunt it down.

more options
In reply to jscher2000

Thank you. I think I've narrowed it down. However, I'm not so sure how to implement that in Powershell.

switch (choice) {

   case 2: // Quit
     if (neverAsk.value)
       Services.prefs.setBoolPref("browser.showQuitWarning", false);
     break;
   case 1: // Cancel
     aCancelQuit.QueryInterface(Ci.nsISupportsPRBool);
     aCancelQuit.data = true;
     break;
   case 0: // Save & Quit
     this._saveSession = true;
     if (neverAsk.value) {
       // always save state when shutting down
       Services.prefs.setIntPref("browser.startup.page", 3);
     }
     break;
   }

Bewurke troch SAI157 op