1
所有窗口,我試着檢索一些信息(X,Y,寬度,高度和標題)在Windows上所有打開的窗口中有一個簡單的C++代碼(見下文):檢索打開在Windows
#include <iostream>
#include <windows.h>
using namespace std;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int iCmdShow)
{
EnumWindows(EnumWindowsProc, NULL);
//system("PAUSE");
return 0;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char class_name[255];
char title[255];
int tmpWidth;
int tmpHeight;
HWND currenthwnd;
RECT WindowRect;
GetClassName(hwnd,class_name, sizeof(class_name));
GetWindowText(hwnd,title,sizeof(title));
GetWindowRect(hwnd,&WindowRect);
//if(WindowRect.left>-50 && title != "" && title != NULL && strlen(title)>0){
tmpHeight = WindowRect.bottom - WindowRect.top;
tmpWidth = WindowRect.right - WindowRect.left;
cout <<"@@##@@"<<title<<",(@@#@@)";
cout <<WindowRect.left<<",(@@#@@)";
cout <<WindowRect.top<<",(@@#@@)";
cout <<tmpWidth<<",(@@#@@)";
cout <<tmpHeight<<",(@@#@@)";
currenthwnd=GetForegroundWindow();
if (currenthwnd!=hwnd){
cout <<title<<",(@@#@@)false";
}else{
cout <<title<<",(@@#@@)true";
}
//}
return TRUE;
}
但我遇到了這個代碼的一些問題,我也嘗試使用Get-Process函數的PowerShell,但是這個函數不會返回所有打開的窗口,而是返回所有現有的進程。
如何檢索標題,x,y,所有打開窗口的高度?
感謝您的幫助
你遇到了什麼問題? – Default
你能更具體一點'我遇到了這個代碼的一些問題'? –