#include <windows.h>
#pragma comment(lib, "user32.lib")
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam)
{
char buff[250]= {0};//全部填充为0
::GetWindowTextA(hwnd,(LPSTR)buff,sizeof(buff));//获取windows窗口标题
qDebug()<<"buff================="<<buff;
if(strstr(buff,".ppt"))
{
::SetWindowPos(hwnd,nullptr,0,0,100,100,SWP_NOMOVE|SWP_NOSIZE);
return FALSE;
// break;
}
return TRUE;//如果返回FALSE的话,则回调函数会停止
}
void MainWindow::on_pushButton_clicked()
{
::EnumWindows(EnumWindowsProc,0);
// SetForegroundWindow
/*
HWND h = ::GetWindow(::GetDesktopWindow(),GW_CHILD);//
while(h!=NULL)
{
char buff[250]= {0};//全部填充为0
::GetWindowTextA(h,(LPSTR)buff,sizeof(buff));
qDebug()<<"buff=============="<<buff;
qDebug()<<"strstr=========="<<strstr(buff,".ppt");
if(strstr(buff,".ppt"))
{
::SetWindowPos(h,nullptr,0,0,100,100,SWP_NOMOVE|SWP_NOSIZE);
break;
}
h = ::GetWindow(h,GW_HWNDNEXT);//GW_HWNDNEXT 获取他的下一个,也就是邻居,就是他的下一个窗口的句柄
}
*/
}#include <windows.h>
#pragma comment(lib, "user