Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I obtain a list of currently running applications?

I want to programmatically obtain a list of running (desktop) applications, and then I want to display this list to the user. It should be something similar to the application list displayed in the Windows Task Manager.

How can I create this in C#? Specifically, I need a way to obtain that list of currently running applications.

like image 814
James Avatar asked Dec 09 '10 06:12

James


People also ask

How do you see what applications are running on Ubuntu?

Open the terminal window on Ubuntu Linux. For remote Ubuntu Linux server use the ssh command for log in purpose. Type the ps aux command to see all running process in Ubuntu Linux. Alternatively, you can issue the top command/htop command to view running process in Ubuntu Linux.

How do you see what programs are currently running?

You can start Task Manager by pressing the key combination Ctrl + Shift + Esc. You can also reach it by right-clicking on the task bar and choosing Task Manager. Under Processes>Apps you see the software that is currently open. This overview should be straight forward these are all the programs you are currently using.

How do I find out what programs are running in the background Windows 10?

To see what apps run on your machine, search "background apps" and select the first option you see. You will go to System Settings > Background Apps and can see what apps are running in the background on your machine. Here you may also turn off and on these apps.


1 Answers

You can use the Process.GetProcesses method to provide information about all of the processes that are currently running on your computer.

However, this shows all running processes, including ones that are not necessarily shown on the taskbar. So what you'll need to do is filter out those processes that have an empty MainWindowTitle.The above-linked documentation explains why this works:

A process has a main window associated with it only if the process has a graphical interface. If the associated process does not have a main window (so that MainWindowHandle is zero), MainWindowTitle is an empty string ("").

So, you could use something like the following code, which will print out (to a console window) a list of all currently running applications that are visible on your taskbar:

Process[] processes = Process.GetProcesses();
foreach (var proc in processes)
{
   if (!string.IsNullOrEmpty(proc.MainWindowTitle))
        Console.WriteLine(proc.MainWindowTitle);
}
like image 134
Cody Gray Avatar answered Nov 06 '22 19:11

Cody Gray