#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
EnumWindows([](HWND hwnd, LPARAM lParam) {
DWORD pid = 0;
GetWindowThreadProcessId(hwnd, &pid);
if (pid == GetCurrentProcessId()) // 判断pid
{
char text[1024];
GetWindowTextA(hwnd, (LPSTR)text, 1024); // 必须含有标题文字
if (strlen(text) != 0 && IsWindowVisible(hwnd))
{
// printf("%s
", text);
targetWindow = hwnd;
return FALSE;
}
}
return TRUE;
}, 7632);
return 0;
}