OSDN Git Service

v0.0.1 release
[winautomata/winautomata.git] / enum_windows.c
1 #include <windows.h>
2 #include <stdio.h>
3
4 static HWND gForground;
5
6 BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lp) 
7 {
8     TCHAR strWindowText[1024];
9     GetWindowText(hwnd, strWindowText, 1024);
10
11     TCHAR strWindowClass[1024];
12     GetClassName(hwnd, strWindowClass, 1024);
13
14     RECT rc;
15     GetWindowRect(hwnd, &rc);
16
17     printf("%s (%s) %d %d %d %d", strWindowClass, strWindowText, rc.left, rc.right, rc.top, rc.bottom);
18
19     if(hwnd == gForground) {
20         printf(" FORGROUND");
21     }
22
23     printf("\n");
24
25     return TRUE;
26 }
27
28 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
29             PSTR lpCmdLine, int nCmdShow)
30 {
31     gForground = GetForegroundWindow();
32
33     EnumWindows(EnumWindowsProc, 0);
34     return 0;
35 }
36