屏幕复制-(这个窗口是最小化的)
需要截屏的程序是别人的,用于监测数据,一定条件下会显示不同的图片和文字.
我定时(每分钟两次)需要截到这个窗口的屏幕,识别图像,如果发现显示了红灯,就把文字发给另一部机(我工作用的电脑).全部都做好了.
现在的问题是,截屏的这个函数,我必须把这个窗口调到最前面,可是我这部机并不专门跑这个程序,如果按这个函数,每30秒把这个窗口放到前面来,会干扰一些其它的操作.
有没有办法在这个窗口最小化时,也复制它的样子出来.
谢谢!
------------------------------------------------------
HWND hWndPrev= ::FindWindow(NULL,"系统数据监测");
if (hWndPrev){
//把它调到最前
::ShowWindow(hWndPrev,SW_SHOW);
::SetForegroundWindow(hWndPrev);
Sleep(1000);
if (IsWindow(hWndPrev)){
RECT lc;
::GetWindowRect(hWndPrev, &lc);
if (lc.top>=0 || lc.bottom>=0 && lc.left>=0 || lc.right>=0){
char * lc_body;
CDC *pDC;//屏幕DC
pDC = CDC::FromHandle(::GetDC(hWndPrev));//获取当前整个屏幕DC
int BitPerPixel = pDC->GetDeviceCaps(BITSPIXEL);//获得颜色模式
tagBITMAPINFO ls_info;
tagBITMAPFILEHEADER ls_header;
HDC lul_whdc = ::GetDC(::GetDesktopWindow());
if (lul_whdc==NULL){
return;
}
HDC hbuffer = ::CreateCompatibleDC(lul_whdc);
if (hbuffer == NULL){
::ReleaseDC(0,lul_whdc);
return;
}
HBITMAP hbmp = ::CreateCompatibleBitmap(lul_whdc, lc.right - lc.left , lc.bottom - lc.top ) ;
if (hbmp == NULL){
::ReleaseDC(0,lul_whdc);
::DeleteDC(hbuffer);
return;
}
if (::SelectObject(hbuffer,hbmp) == NULL){
::ReleaseDC(0,lul_whdc);
::DeleteDC(hbuffer);
::DeleteObject(hbmp);
return;
}
if (::BitBlt(hbuffer,0, 0, lc.right, lc.bottom, lul_whdc,lc.left,lc.top , SRCCOPY) == NULL){
::ReleaseDC(0,lul_whdc);
::DeleteDC(hbuffer);
::DeleteObject(hbmp);
return;
}
::ReleaseDC(0,lul_whdc);
ls_info.bmiHeader.biSize = 40;
ls_info.bmiHeader.biWidth = lc.right - lc.left;
ls_info.bmiHeader.biHeight = lc.bottom - lc.top;
ls_info.bmiHeader.biPlanes = 1;
ls_info.bmiHeader.biBitCount = BitPerPixel;
ls_info.bmiHeader.biCompression = 0;
ls_info.bmiHeader.biSizeImage = 0;
ls_info.bmiHeader.biXPelsPerMeter = 0;
ls_info.bmiHeader.biYPelsPerMeter = 0;
ls_info.bmiHeader.biClrUsed = 0;
ls_info.bmiHeader.biClrImportant = 0;
ls_header.bfSize = 14;
ls_header.bfOffBits = 14 + 40;
ls_header.bfType = 19778;
ls_header.bfReserved1 = 0;
ls_header.bfReserved2 = 0;
long ll_len = sizeof(ls_info.bmiHeader)+
sizeof(ls_header)+
(lc.right - lc.left + 1) * (lc.bottom - lc.top + 1) * (BitPerPixel) / 8 ;
lc_body = new char[ll_len];
::RtlMoveMemory(lc_body,&ls_header,sizeof(ls_header));
::RtlMoveMemory(lc_body + sizeof(ls_header),&ls_info.bmiHeader,sizeof(ls_info.bmiHeader));
::GetDIBits(hbuffer,hbmp,0,lc.bottom - lc.top,lc_body + sizeof(ls_header) + sizeof(ls_info.bmiHeader),&ls_info, 0);
::DeleteDC(hbuffer);
::DeleteObject(hbmp);
::DeleteDC(hbuffer);
//输出
CString ls_file_name;
ls_file_name = "f:\\desktop\\系统数据监测\\B"+shuf::DatetimeToString(shuf::Now(),"YYYYMMDDHHMMSS")+".bmp";
shuf::write_file(ls_file_name,lc_body,ll_len);
delete []lc_body;
return;
}
}
}
我定时(每分钟两次)需要截到这个窗口的屏幕,识别图像,如果发现显示了红灯,就把文字发给另一部机(我工作用的电脑).全部都做好了.
现在的问题是,截屏的这个函数,我必须把这个窗口调到最前面,可是我这部机并不专门跑这个程序,如果按这个函数,每30秒把这个窗口放到前面来,会干扰一些其它的操作.
有没有办法在这个窗口最小化时,也复制它的样子出来.
谢谢!
------------------------------------------------------
HWND hWndPrev= ::FindWindow(NULL,"系统数据监测");
if (hWndPrev){
//把它调到最前
::ShowWindow(hWndPrev,SW_SHOW);
::SetForegroundWindow(hWndPrev);
Sleep(1000);
if (IsWindow(hWndPrev)){
RECT lc;
::GetWindowRect(hWndPrev, &lc);
if (lc.top>=0 || lc.bottom>=0 && lc.left>=0 || lc.right>=0){
char * lc_body;
CDC *pDC;//屏幕DC
pDC = CDC::FromHandle(::GetDC(hWndPrev));//获取当前整个屏幕DC
int BitPerPixel = pDC->GetDeviceCaps(BITSPIXEL);//获得颜色模式
tagBITMAPINFO ls_info;
tagBITMAPFILEHEADER ls_header;
HDC lul_whdc = ::GetDC(::GetDesktopWindow());
if (lul_whdc==NULL){
return;
}
HDC hbuffer = ::CreateCompatibleDC(lul_whdc);
if (hbuffer == NULL){
::ReleaseDC(0,lul_whdc);
return;
}
HBITMAP hbmp = ::CreateCompatibleBitmap(lul_whdc, lc.right - lc.left , lc.bottom - lc.top ) ;
if (hbmp == NULL){
::ReleaseDC(0,lul_whdc);
::DeleteDC(hbuffer);
return;
}
if (::SelectObject(hbuffer,hbmp) == NULL){
::ReleaseDC(0,lul_whdc);
::DeleteDC(hbuffer);
::DeleteObject(hbmp);
return;
}
if (::BitBlt(hbuffer,0, 0, lc.right, lc.bottom, lul_whdc,lc.left,lc.top , SRCCOPY) == NULL){
::ReleaseDC(0,lul_whdc);
::DeleteDC(hbuffer);
::DeleteObject(hbmp);
return;
}
::ReleaseDC(0,lul_whdc);
ls_info.bmiHeader.biSize = 40;
ls_info.bmiHeader.biWidth = lc.right - lc.left;
ls_info.bmiHeader.biHeight = lc.bottom - lc.top;
ls_info.bmiHeader.biPlanes = 1;
ls_info.bmiHeader.biBitCount = BitPerPixel;
ls_info.bmiHeader.biCompression = 0;
ls_info.bmiHeader.biSizeImage = 0;
ls_info.bmiHeader.biXPelsPerMeter = 0;
ls_info.bmiHeader.biYPelsPerMeter = 0;
ls_info.bmiHeader.biClrUsed = 0;
ls_info.bmiHeader.biClrImportant = 0;
ls_header.bfSize = 14;
ls_header.bfOffBits = 14 + 40;
ls_header.bfType = 19778;
ls_header.bfReserved1 = 0;
ls_header.bfReserved2 = 0;
long ll_len = sizeof(ls_info.bmiHeader)+
sizeof(ls_header)+
(lc.right - lc.left + 1) * (lc.bottom - lc.top + 1) * (BitPerPixel) / 8 ;
lc_body = new char[ll_len];
::RtlMoveMemory(lc_body,&ls_header,sizeof(ls_header));
::RtlMoveMemory(lc_body + sizeof(ls_header),&ls_info.bmiHeader,sizeof(ls_info.bmiHeader));
::GetDIBits(hbuffer,hbmp,0,lc.bottom - lc.top,lc_body + sizeof(ls_header) + sizeof(ls_info.bmiHeader),&ls_info, 0);
::DeleteDC(hbuffer);
::DeleteObject(hbmp);
::DeleteDC(hbuffer);
//输出
CString ls_file_name;
ls_file_name = "f:\\desktop\\系统数据监测\\B"+shuf::DatetimeToString(shuf::Now(),"YYYYMMDDHHMMSS")+".bmp";
shuf::write_file(ls_file_name,lc_body,ll_len);
delete []lc_body;
return;
}
}
}
...全文
相关推荐
用VC++写的屏幕截图软件,并可以最小化成托盘图标
标题 "用VC++写的屏幕截图软件,并可以最小化成托盘图标" 描述了一款使用Microsoft Visual C++(简称VC++)开发的屏幕截图应用程序,它具有将窗口最小化到系统托盘区域的功能。
支持全屏/区域/窗口捕捉的屏幕图像截取工具设计与实现
屏幕捕捉是指通过软件手段获取计算机显示内容的技术,其核心目标是将图形界面中的像素数据以图像形式提取并保存。根据捕获范围的不同,可分为全屏捕捉、区域捕捉和窗口级捕捉三类。全屏捕捉适用于监控或录屏场景;区域捕捉常用于用户自定义选区截图;窗口级捕捉则聚焦于特定应用程序界面,支持对最小化或后台窗口的内容提取。
VC++屏幕取色器(或鼠标钩子)
该项目基于MFC框架开发,实现了一个屏幕取色工具,具备实时获取鼠标坐标、像素颜色值、窗口句柄等信息的功能。通过属性页界面提供配置选项,支持自动复制颜色值、窗口置顶、最小化启动等功能,并利用配置文件持久
mfc最小化,基于对话框,mfc最小化
使用`BitBlt()`函数将内存中的位图复制到屏幕上的指定位置,实现了按钮的绘制。#### 消息处理- 当用户点击最小化按钮时,程序将响应`WM_NCLBUTTONDOWN`消息。
c#,csharp缩略图方式获取任何窗口,包括最小化的窗口,包括DX窗口,静止窗口,视频窗口,游戏窗口,速度极快
**复制窗口内容到内存DC**: - 使用`BitBlt`函数将窗口的设备上下文内容复制到内存DC。这一步实际上完成了截图。6.


