I am working on a program which works when specific program is currently in focus(user are using it).
To get the processes I use GetProcesses()
, but it does not return all of the processes. For example, I cant get CREO Parametric processes.
Is there are other way for me to approach this problem?
Method I use:
public string getActiveWindowName()
{
try
{
var activatedHandle = GetForegroundWindow();
Process[] processes = Process.GetProcesses();
foreach (Process clsProcess in processes)
{
if (activatedHandle == clsProcess.MainWindowHandle)
{
string processName = clsProcess.ProcessName;
Debug.WriteLine(processName);
return processName;
}
}
}
catch { }
return null;
}