How to handle multiple process windows at the same time

32 Views Asked by At

sorry I'm Vietnamese and use Google translate to write in English, so everyone can help answer the question I mentioned, I'm stuck on the problem of handling the process window:

here is my code:

string[] HandleParts = {"MyWindow1","MyWindow2","MyWindow3","etc.."}
while (flag)
{
    var s = new FindData()
    {
       ClassName = "#32770",
       WindowName = string.Join(@" ", HandleParts)
    };
    EnumWindows(EnumProc, ref s);
    var result = s.Result.FirstOrDefault();
    if (result != InPtr.Zero)
    {
          EnumAllChilds(result, InPtr.Zero);
          GetForegroundWindow((int)result).ToInt32();
          PostMessage(result, 0x0, 0, 0);
    }
    else
    {
            Console.WriteLine("WindowHandle Not Found!");
            break;
    }
}

I don't understand why it only works with the first 1 window in the listed list, I need help to fix the problem.

0

There are 0 best solutions below