Pop-up window killer is a program that can automatically close the IE pop-up window, it works in the system tray, according to a certain interval to detect the IE window, and then close the pop-up form. Finally, it also provides the ability to use a hotkey to kill pop-up windows.
Although there are already similar programs written in C + +, this article is about using C # to implement these features, and the scenario described in this article is faster than the way to find Windows.
This is a new topic, and we can see many similar programs on the Internet. But I would also like to take this opportunity to explain how the following techniques are implemented in C #:
System Tray
Program switching
Timing controls
Find window
System Hotkey
Generate a System tray program
First, a new C # Windows form program is generated, and the NotifyIcon control is dragged from the Toolbox onto the form, as shown in the following illustration:
To add a pallet to a C # Windows Form program
To ensure that the icon of the system tray and the icon of the application are consistent, we use a common icon file A.ico to set the system tray icon and the application icon.
In order for the program to not appear on the toolbar, we can set the Visible property of the form to false. This can be implemented directly in the form Properties window.
This. ShowInTaskbar = false;
So far, the system tray has been basically good, but we have not set the right menu, nor the program to show and hide the function.
Program switching
First, the program's main form can be selected for display or hidden depending on the state, and in addition, we can use WindowState to set the state of the form:
public void HideApp()
{
this.WindowState = FormWindowState.Minimized;
Hide();
}
public void ShowApp()
{
Show();
this.WindowState = FormWindowState.Normal;
}