检索在Windows上打开的所有窗口 我尝试用一个简单的C++代码(在下面)中检索Windows上所有打开的窗口的一些信息(x,y,宽度,高度和title): #包括 #包括 使用名称空间std; BOOL回调EnumWindowsProc(HWND-HWND,LPARAM-LPARAM); int WINAPI WinMain(HINSTANCE HINSTANCE、HINSTANCE hPrevInstance、PSTR pCmdLine、int iCmdShow) { EnumWindows(EnumWindowsProc,NULL); //系统(“暂停”); 返回0; } BOOL回调EnumWindowsProc(HWND-HWND,LPARAM-LPARAM) { 字符类名称[255]; 字符标题[255]; int tmpWidth; 国际电视台; HWND当前HWND; 矩形窗口矩形; GetClassName(hwnd,class_name,sizeof(class_name)); GetWindowText(hwnd,title,sizeof(title)); GetWindowRect(hwnd和WindowRect); //如果(WindowRect.left>-50&&title!=“”&&title!=NULL&&strlen(title)>0){ tmpHeight=WindowRect.bottom-WindowRect.top; tmpWidth=WindowRect.right-WindowRect.left; cout

检索在Windows上打开的所有窗口 我尝试用一个简单的C++代码(在下面)中检索Windows上所有打开的窗口的一些信息(x,y,宽度,高度和title): #包括 #包括 使用名称空间std; BOOL回调EnumWindowsProc(HWND-HWND,LPARAM-LPARAM); int WINAPI WinMain(HINSTANCE HINSTANCE、HINSTANCE hPrevInstance、PSTR pCmdLine、int iCmdShow) { EnumWindows(EnumWindowsProc,NULL); //系统(“暂停”); 返回0; } BOOL回调EnumWindowsProc(HWND-HWND,LPARAM-LPARAM) { 字符类名称[255]; 字符标题[255]; int tmpWidth; 国际电视台; HWND当前HWND; 矩形窗口矩形; GetClassName(hwnd,class_name,sizeof(class_name)); GetWindowText(hwnd,title,sizeof(title)); GetWindowRect(hwnd和WindowRect); //如果(WindowRect.left>-50&&title!=“”&&title!=NULL&&strlen(title)>0){ tmpHeight=WindowRect.bottom-WindowRect.top; tmpWidth=WindowRect.right-WindowRect.left; cout,c++,winapi,powershell,C++,Winapi,Powershell,在powershell中,您可以使用该模块并编写如下内容: Get-Process | Where-Object {$_.MainWindowTitle -ne ""} | % {$_.processname + "-" + $_.mainwindowtitle; Get-WindowPosition -Window $_.handle } 这是我的实际powershell窗口的结果示例: powershell - Posh - Admin Location : {X=4,Y

在powershell中,您可以使用该模块并编写如下内容:

Get-Process | Where-Object {$_.MainWindowTitle -ne ""}  | 
% {$_.processname + "-" + $_.mainwindowtitle;
       Get-WindowPosition -Window $_.handle }
这是我的实际powershell窗口的结果示例:

powershell - Posh - Admin
Location : {X=4,Y=44}
Size     : {Width=885, Height=129}
X        : 4
Y        : 44
Width    : 885
Height   : 129
Left     : 4
Top      : 44
Right    : 889
Bottom   : 173
IsEmpty  : False

你遇到了什么问题?你能更具体地说一下“我在这段代码中遇到了一些问题”吗?
powershell - Posh - Admin
Location : {X=4,Y=44}
Size     : {Width=885, Height=129}
X        : 4
Y        : 44
Width    : 885
Height   : 129
Left     : 4
Top      : 44
Right    : 889
Bottom   : 173
IsEmpty  : False