I am trying to reproduce alt tab on code,but I am having trouble with getting only processes that have a window and sorting them by order of use like, just like alt + tab would do.
Process[] ram = Process
.GetProcesses()
.Where(x => tryGetHandle(x) != IntPtr.Zero)
.ToArray();
List<IntPtr> hwnds = new List<IntPtr>();
foreach(Process proc in ram)
{
hwnds.Add(proc.Handle);
}
I have a list of handles because I was trying to get the Z order of them, but the answer I found here is not working for me, the result end up being every z on the list is -1.
Context: I am making a work for my computer interface class on college and I am making an app that connects with a cellphone to read its sensors and identify which monitor the person is looking to and then change focus (alt+tab) to the last window used on that monitor.