The problem is that, I want to get handles of all visible windows. Up to now I have achieved to get hwnd of a window which includes a substring. Here is my code. The block i have mentioned is in the comment, but i couldn't find any method to check the visibility of a window.
Thanks in advance :)
#include <string.h>
#include <tchar.h>
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
vector<HWND> asd,myVector;
HWND temp;
BOOL CALLBACK addToVector(HWND hwnd, LPARAM windowName)
{
myVector.push_back(hwnd);
//to get desired windows filtering by window name as substring
/*
TCHAR windowTitle[512];
if (GetWindowText(hwnd, windowTitle, 512))
{
if (_tcsstr(windowTitle, LPCTSTR(windowName)) != NULL)
{
myVector.push_back(hwnd);
}
}
*/
return true;
}
int main()
{
char substring[] = "chrome";
EnumWindows(addToVector, (LPARAM)substring);
cout << myVector.size() << endl;
getchar();
return 0;
}
You can determine if a window is visible by calling IsWindowVisible()
.
if(IsWindowVisible(hwnd))
{
myVector.push_back(hwnd);
}