Jump to content
Macro Express Forums

closing a tab


Recommended Posts

You didn't specify a specific tab. This is a typical reason why I started programming all my web automation in .NET. Too many little limitations.

 

I can't think of any way to do it without using some sort of browser automation facility. The only left field thing I could think of was that in the early days you could disable tabs in your browser and have them all individual windows. If you did that MEP could see the window titles. But I don' think that's what you want.

Link to comment
Share on other sites

Here's a method that's a little crude, but it worked when I tested it in Firefox and Chrome.

 

IF you know the tab title, you can treat it like a window title.

Let's say the tab title you want to close contains the words "real estate".

 

Your macro can mouse-click sequentially on each tab at the top of the screen, moving left to right, to highlight each tab.

Then after each click, say

If Window Title "real estate" is on top
Text Type: <CTRLD>w<CTRLU>
End If

 

You have to be careful where you click on the tab, so you won't click on the "x" that closes it. I found that clicking near the top edge worked best.

Also, tab width will vary -- get narrower -- if you have lots of tabs open, so the increment as you click left to right has to be small enough not to jump right over a tab. This also means you may click on the same tab more than once, but if it is not the tab you want to close then the macro will just ignore it each time.

 

I didn't test timing, so I don't know whether this will be fast enough if there are many tabs open. Also there may be a slight delay after you click and before the tab is active, so you may have to include a short delay before checking window title. Probably best to close your eyes while the macro is working so you won't be dazzled by all the tabs flashing by. :o

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...