IE9 the tool to close the current tab by double-clicking the tab page

Source: Internet
Author: User
Tags time interval

How to implement IE9 double-click to close the current tab page (Tab tab page) functionality, the rationale for this function is as follows:

1, set up the global mouse hook, get double-click the message when the tab, triggering the tab is double-clicked event.

2, send the CTRL+W keyboard message, trigger the shortcut key function closes the current tab page.

Here are a few questions to solve:

How to get the mouse double-click event:

Spy + + detected after detection, found that the tab bar is a type of Directuihwnd class, it is a TabControl, does not support the mouse double-click the message, therefore, you need to determine according to the MouseUp message is a double click message ( Judged by the time interval of two times MouseUp).

How to tell if a tab page is double-clicked:

Because a global hook is created, all mouse messages are intercepted, so filtering is done here. The specific condition is: the control class of the mouse trigger point is directuihwnd, and its process is ie.

How to close the current tab page:

This is relatively simple, direct call keybd_event send Ctrl+w can.

It's not difficult to implement this feature, but when I want to integrate it into BHO, I have a problem--when IE turns on protection, it can't get the global mouse hook message.

There are two ways to solve this problem:

Turn off protection mode

A new hook program is written to intercept the mouse message and then start the process in BHO.

Method 1 reduces the security of the browser, which is naturally undesirable. Method 2 can solve this problem, but there is an additional process, although it can be hidden, users do not feel, but always not cool. Weighed repeatedly, finally chose Method 2. (I'm not familiar with Windows programming, please let me know if there's a better way)

Use environment: Win 7+ie9+.net 4.0, other environments can not be implemented. Win 7 users need to install. NET 4.0 to start the program.

How to use:

Open IE9 After the program can be manually started, it will automatically hide in the background (through the process manager can see the program, do not stop the point), and then have a double click IE9 tab button to close the current tab page function. The program also shuts down automatically when the IE9 is closed.

Another way to quickly close tabs is to close the tabs by clicking the Wheel key in the middle of the mouse in the tab (label). Small knitting feel This method is more rapid than double click off the method.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.