Ask before closing the last two browser tabs open in Google

I'm sure there is a way to do this so I'm not going to start the question with "Is there a way..."

What I want to do is have the macro check to see if there are only 2 browser tab's open in Chrome and ask if I want to close them or better yet disregard the portion of the macro that I have that is set to close tabs 3 & 4.

What's happening is I forget that I already closed tabs 3 & 4 and when I run the macro it closes tabs 1 & 2.



As you surmised, there is indeed a way to do this, and it's easier than you might think. You can use a Switch/Case action that checks if the CHROMETABCOUNT function (which returns the number of tabs in the frontmost Chrome window) is 2 or more than 2, and performs different actions accordingly:

Smart Tab Close.kmmacros (4.3 KB)
12 PM

Very cool.
Thank you Gabe.
I’ll try it later.