Reputation: 3891
I am trying to get all the window handles of applications that have a taskbar icon only.
The solutions I have converted to C# that have failed:
Enumerate windows like alt-tab does
Enumerate windows like alt-tab does
Enumerate windows like alt-tab does
And a couple that I lost track of already. All these solutions either crash or bring up windowless processes like svchost, plugin processes, etc.
Basically I just need the windows that are actively available in the task bar with icons. I am using the window handle of
Process.MainWindowHandle
What are some working solutions to this? Is there a thread with a working solution that I missed?
Upvotes: 0
Views: 3654
Reputation: 12894
Try retrieving all processes where the MainWindowTitle property is set.
It doesn't feel like a particularly elegant solution, but it worked for me, bringing back only those applications which were running and visibly open in the taskbar.
List<Process> taskBarProcesses = Process.GetProcesses().
Where(p => !string.IsNullOrEmpty(p.MainWindowTitle))
.ToList();
Upvotes: 1