[英]Getting handle of externally running visible windows c++
問題是,我想獲取所有可見窗口的句柄。 到目前為止,我已經實現了獲取包含子字符串的窗口的功能。 這是我的代碼。 我已經提到的塊在注釋中,但是我找不到任何方法來檢查窗口的可見性。
提前致謝 :)
#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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.