Windows获取窗口列表
程序员文章站
2022-03-19 15:01:16
...
ENV
- Windows 10
- Visual Studio 2017
Source
#include <Windows.h>
#include <Dwmapi.h>
#include <iostream>
#pragma comment(lib, "dwmapi.lib")
int main(int argc, char* argv[])
{
auto hwnd = GetDesktopWindow();
hwnd = GetWindow(hwnd, GW_CHILD);
auto counter = 0;
while (hwnd != NULL) {
RECT rect;
// https://*.com/questions/34583160/winapi-createwindow-function-creates-smaller-windows-than-set
// GetWindowRect(hwnd, &rect);
DwmGetWindowAttribute(hwnd, DWMWA_EXTENDED_FRAME_BOUNDS, &rect, sizeof(RECT));
char name[255];
GetWindowText(hwnd, name, 255);
std::cout << "#" << counter++ << " " << name
<< ": (" << rect.left << ", " << rect.top << ") - "
<< rect.right - rect.left << " x " << rect.bottom - rect.top << std::endl;
hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
}
return 0;
}
上一篇: plot 函数详解
下一篇: python Plot 画图用法