Get a list of opened windows C#

With the following method you can list all opened windows using C#.

public void ListOpenedWindows()
{
	IntPtr hwnd;
	foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses())
	{
		if ((hwnd = proc.MainWindowHandle) != IntPtr.Zero)
			Console.WriteLine(hwnd.ToString() + " " + proc.MainWindowTitle);
	}
}
Categories: C# Tags: , , , ,
%d bloggers like this: