Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# remove 3rd party application from taskbar

How to remove an 3rd party application from the Windows taskbar by its handle?

I've found this: Remove application from taskbar with C# wrapper?

But it doesnt worked for me. It only sets another style (small x to close, no maximize/minimize button) to the Window i selected (notepad).

Any ideas about this?

EDIT: I dont want to remove MY application from the taskbar, i want to remove an external application by handle

like image 580
cyptus Avatar asked May 09 '12 11:05

cyptus


2 Answers

If you have the handle to the window you can call ShowWindow() through the Win32 API. Then you can do:

// Let the window disappear (even from taskbar)
ShowWindow(this.Handle, WindowShowStyle.Hide);

// Revive the window back to the user
ShowWindow(this.Handle, WindowShowStyle.ShowNoActivate);

So from now, all your problem is to get the handle of the window you like to hide:

Process[] procs = Process.GetProcesses();
IntPtr hWnd;
foreach(Process proc in procs)
{
   if ((hWnd = proc.MainWindowHandle) != IntPtr.Zero)
   {
      Console.WriteLine("{0} : {1}", proc.ProcessName, hWnd);
   }
}
like image 66
Oliver Avatar answered Sep 24 '22 13:09

Oliver


To hide it from windows task bar you just need to set ShowInTaskbar property to false :

this.ShowInTaskbar = false;

As for moving of windows you can use spy++ to check windows events and identify it.

like image 30
Zaki Avatar answered Sep 25 '22 13:09

Zaki