获取外部运行可见windows c++的处理



问题是,我想获得所有可见窗口的句柄。到目前为止,我已经实现了一个窗口的hwnd,其中包括一个子字符串。这是我的代码。我提到的块是在评论中,但我找不到任何方法来检查窗口的可见性。

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;
}

您可以通过调用IsWindowVisible()来确定窗口是否可见。

if(IsWindowVisible(hwnd))
{
    myVector.push_back(hwnd);
}

最新更新