問題は、表示されているすべてのウィンドウのハンドルを取得したいということです。これまで、部分文字列を含むウィンドウのhwndを取得することを達成しました。これが私のコードです。私が言及したブロックはコメントにありますが、ウィンドウの可視性をチェックする方法が見つかりませんでした。
前もって感謝します :)
#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;
}
を呼び出すことで、ウィンドウが表示されているかどうかを確認できますIsWindowVisible()
。
if(IsWindowVisible(hwnd))
{
myVector.push_back(hwnd);
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加