Now I use this method to get all the processes:

Process[] processes = GetAllProcesses(); 

How can I get only those processes that are displayed on the taskbar?

    1 answer 1

    As far as I can see, these processes can be obtained by filtering from your list those that have a MainWindowHandle greater than zero:

     Process[] processes = System.Diagnostics.Process.GetProcesses(); var apps = processes.Where(x => x.MainWindowHandle != IntPtr.Zero); 

    In principle, the same result can be obtained by checking Handle! = Null, but you can get an error about the absence of rights if you start from under the account without admin rights.

    While launched drew attention. Outlook notifications (pop up on the taskbar) for some reason are not displayed in the task list, although they are visually visible even on the taskbar. Do you need such notifications?

    • one
      By the way, is it correct to say "more than zero" in the context of InPtr? From the point of view of links a la C ++, it seems to be incorrect, in terms of the fact that this is a special int for combining int32 and int64, it seems to be as possible. - AK
    • Most of the garbage is discarded, but ScriptedSandbox64 and ShellExperienceHost both remained and remained, but in the manager they are marked as "background". Adding them to the exceptions is not a problem, but what if the user has other garbage? - Vitali
    • @Vitaly I do not have such processes, but try filtering out more processes with an empty MainWindowTitle - it is likely that such background processes will be empty. - AK