How to get active process name in C#?
I know that I must use this code:
[DllImport(\"user32.dll\")] private static extern IntPtr GetForegroundWindow(
public void GetProcessNames() { List windowNames = new List(); foreach (Process window in Process.GetProcesses()) { if (window.MainWindowHandle != IntPtr.Zero) { windowNames.Add(window.MainWindowTitle); } // It's that simple } }