I need to find all the open Window with graphic interfaces and their processes and I don't really know how to do it. I've written some code but I just succeeded in finding open windows:
HWND hwnd = GetForegroundWindow(); // get handle of currently active window
GetWindowText(hwnd, wnd_title, sizeof(wnd_title));
cout << "Window with focus: " << wnd_title << endl << endl;
EnumWindows(EnumWindowsProc, 0);
EnumWindowsProc is defined like this:
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char class_name[80];
char title[80];
if (IsWindowVisible(hwnd)) {
GetClassName(hwnd, class_name, sizeof(class_name));
GetWindowText(hwnd, title, sizeof(title));
cout << "Window title: " << title << endl;
cout << "Class name: " << class_name << endl << endl;
}
return TRUE;
}
Someone can help me?