How to get all running applications with a visible main window in Windows with C# WinForms

1 Answer

0 votes
private void button1_Click(object sender, EventArgs e)
{
    listBox1.Items.Clear();

    foreach (Process process in Process.GetProcesses())
    {
        if (!string.IsNullOrEmpty(process.MainWindowTitle))
        {
            listBox1.Items.Add($"{process.ProcessName} - {process.MainWindowTitle}");
        }
    }
}


/*
run:

WhatsApp.Root - WhatsApp
Notepad - *private void button1_Click(object s - Notepad
SystemSettings - Settings
msedge - Ask a question - CollectiveSolver and 61 more pages - Personal - Microsoft​ Edge
PowerToys.QuickAccess - PowerToys Quick Access (Preview)
devenv - TheProject (Running) - Form1.cs - Microsoft Visual Studio

*/

 



answered Oct 21 by avibootz
...