1

I'm trying to create a keylogger in C# that shows the text that is typed in a RichTextBox and show running apps that are opened in a period of time. E.g. An image in a ListView that contains the icons of apps that are opened in a time and the text typed in a RichTextBox. I've done the keylogging keystrokes recording, but this ListView problem is what I can't hack. Here is what I temporarily have:

private void button1_Click(object sender, EventArgs e)
{
    string appName = Application.ProductName;
    MessageBox.Show(appName);
    //To find the name of the executable
    appName = Path.GetFileName(Application.ExecutablePath);
    MessageBox.Show(appName);
}

This would only show it in a MessageBox, and contains the name and path of the file running only. Not all applications that are running. Any suggestions?

Robin
  • 127
  • 10
  • I think [This](https://stackoverflow.com/questions/648410/how-can-i-list-all-processes-running-in-windows) should point you in the right direction. – Jonathan Willcock Jul 13 '17 at 06:20
  • Thanks, is there any way to get the ListBox to show program history(what the user opened in a period of time)? Thanks again. – Robin Jul 13 '17 at 14:02

1 Answers1

0

You would need a Process array for this, I am not clear as how you want the details to be displayed Something like this would do, but be careful when using the methods in the process class as you can kill a lot of process with it and it may lead to system instability.

using System.Diagnostics;

Process[] processes = Process.GetProcesses();
List<string> namesOfRunningProcesses = new List<string>();
foreach(Process p in processes)
 namesOfRunningProcesses.Add(p.ProcessName);

You can also access other properties of the process like start time, run time etc. A full list of the properties here on this MSDN Link. Then you can do whatever you want, add it to a list view or whatever.

Suraj S
  • 1,019
  • 7
  • 18