How to hide winform or WPF application from "alt+tab" and from task manager's application tab

StackOverflow https://stackoverflow.com/questions/23672595

  •  23-07-2023
  •  | 
  •  

Domanda

I saw many questions and answers related to this topic But I didn't find any better solution. Few solution are lengthy and few doesn't work. Now I want to share a nice and easy solution for this

È stato utile?

Soluzione

How to make application invisible in WPF. just add this XAML code

<Window x:Class="temp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="350" Width="525" ResizeMode="NoResize" WindowState="Minimized" IsTabStop="False" Visibility="Hidden" WindowStyle="None" ShowInTaskbar="False">
<Grid>

</Grid>
</Window>

Height and width dosn't matter only Visibility, WindowStyle and ShowInTaskbar will hide the application from Alt +Tab and from task manager's application tab

Now for Winform: Use Form load event and put this code

private void Form1_Load(object sender, EventArgs e)
{
    this.Opacity = 0; //Declear Opacity = 0 on top
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; //This is most Important part don't use FormBorderStyle.None or something else
    this.WindowState = FormWindowState.Minimized;
    this.ShowInTaskbar = false;
}

This will Hide Winform Application form Alt+tab as well as from task manager's application tab

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top