2019-01-05 20:21:43 +08:00
|
|
|
|
// ScreenSpy.h: interface for the CScreenSpy class.
|
|
|
|
|
|
//
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|
|
|
|
|
|
#define AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_
|
|
|
|
|
|
|
|
|
|
|
|
#if _MSC_VER > 1000
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#endif // _MSC_VER > 1000
|
2025-03-13 23:34:33 +08:00
|
|
|
|
|
2019-01-07 20:46:03 +08:00
|
|
|
|
#define COPY_ALL 1 // <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ֿ鿽<D6BF><E9BFBD><EFBFBD><EFBFBD>added by yuanyuanxiang 2019-1-7<><37>
|
2019-01-20 20:04:11 +08:00
|
|
|
|
#include "CursorInfo.h"
|
2025-03-13 23:34:33 +08:00
|
|
|
|
#include "ScreenCapture.h"
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-05-31 15:49:40 +08:00
|
|
|
|
class EnumHwndsPrintData {
|
|
|
|
|
|
public:
|
|
|
|
|
|
EnumHwndsPrintData() {
|
|
|
|
|
|
memset(this, 0, sizeof(EnumHwndsPrintData));
|
|
|
|
|
|
}
|
|
|
|
|
|
void Create(HDC desktop, int _x, int _y, int w, int h) {
|
|
|
|
|
|
x = _x;
|
|
|
|
|
|
y = _y;
|
|
|
|
|
|
width = w;
|
|
|
|
|
|
height = h;
|
|
|
|
|
|
hDcWindow = CreateCompatibleDC(desktop);
|
|
|
|
|
|
hBmpWindow = CreateCompatibleBitmap(desktop, w, h);
|
|
|
|
|
|
}
|
|
|
|
|
|
EnumHwndsPrintData& SetScreenDC(HDC dc) {
|
|
|
|
|
|
hDcScreen = dc;
|
|
|
|
|
|
return *this;
|
|
|
|
|
|
}
|
|
|
|
|
|
~EnumHwndsPrintData() {
|
|
|
|
|
|
if (hDcWindow) DeleteDC(hDcWindow);
|
|
|
|
|
|
hDcWindow = nullptr;
|
|
|
|
|
|
if (hBmpWindow)DeleteObject(hBmpWindow);
|
|
|
|
|
|
hBmpWindow = nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
HDC GetWindowDC() const {
|
|
|
|
|
|
return hDcWindow;
|
|
|
|
|
|
}
|
|
|
|
|
|
HDC GetScreenDC() const {
|
|
|
|
|
|
return hDcScreen;
|
|
|
|
|
|
}
|
|
|
|
|
|
HBITMAP GetWindowBmp() const {
|
|
|
|
|
|
return hBmpWindow;
|
|
|
|
|
|
}
|
|
|
|
|
|
int X() const {
|
|
|
|
|
|
return x;
|
|
|
|
|
|
}
|
|
|
|
|
|
int Y() const {
|
|
|
|
|
|
return y;
|
|
|
|
|
|
}
|
|
|
|
|
|
int Width()const {
|
|
|
|
|
|
return width;
|
|
|
|
|
|
}
|
|
|
|
|
|
int Height()const {
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
2019-09-07 10:47:50 +08:00
|
|
|
|
private:
|
2025-05-31 15:49:40 +08:00
|
|
|
|
HDC hDcWindow;
|
|
|
|
|
|
HDC hDcScreen;
|
|
|
|
|
|
HBITMAP hBmpWindow;
|
|
|
|
|
|
int x;
|
|
|
|
|
|
int y;
|
|
|
|
|
|
int width;
|
|
|
|
|
|
int height;
|
|
|
|
|
|
};
|
2019-09-07 10:47:50 +08:00
|
|
|
|
|
2025-05-31 15:49:40 +08:00
|
|
|
|
class CScreenSpy : public ScreenCapture
|
|
|
|
|
|
{
|
|
|
|
|
|
protected:
|
|
|
|
|
|
HDC m_hDeskTopDC; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
HDC m_hFullMemDC; // <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
HDC m_hDiffMemDC; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
HBITMAP m_BitmapHandle; // <20><>һ֡λͼ
|
|
|
|
|
|
HBITMAP m_DiffBitmapHandle; // <20><><EFBFBD><EFBFBD>֡λͼ
|
|
|
|
|
|
PVOID m_BitmapData_Full; // <20><>ǰλͼ<CEBB><CDBC><EFBFBD><EFBFBD>
|
|
|
|
|
|
PVOID m_DiffBitmapData_Full; // <20><><EFBFBD><EFBFBD>λͼ<CEBB><CDBC><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
BOOL m_bVirtualPaint;// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
EnumHwndsPrintData m_data;
|
2019-09-07 10:47:50 +08:00
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
public:
|
2025-07-16 04:26:01 +08:00
|
|
|
|
CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk = FALSE, int gop = DEFAULT_GOP, BOOL all = FALSE);
|
2019-09-07 10:47:50 +08:00
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
virtual ~CScreenSpy();
|
2019-01-17 20:41:51 +08:00
|
|
|
|
|
2019-09-07 10:47:50 +08:00
|
|
|
|
int GetWidth()const {
|
|
|
|
|
|
return m_ulFullWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GetHeight() const {
|
|
|
|
|
|
return m_ulFullHeight;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IsZoomed() const {
|
|
|
|
|
|
return m_bZoomed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double GetWZoom() const {
|
|
|
|
|
|
return m_wZoom;
|
|
|
|
|
|
}
|
2019-01-17 20:41:51 +08:00
|
|
|
|
|
2019-09-07 10:47:50 +08:00
|
|
|
|
double GetHZoom() const {
|
|
|
|
|
|
return m_hZoom;
|
2019-01-17 20:41:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const LPBITMAPINFO& GetBIData() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_BitmapInfor_Full;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ULONG GetFirstScreenLength() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-31 15:49:40 +08:00
|
|
|
|
static BOOL PaintWindow(HWND hWnd, EnumHwndsPrintData* data)
|
2019-01-17 20:41:51 +08:00
|
|
|
|
{
|
2025-05-31 15:49:40 +08:00
|
|
|
|
if (!IsWindowVisible(hWnd) || IsIconic(hWnd))
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
|
|
if (!GetWindowRect(hWnd, &rect))
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
HDC hDcWindow = data->GetWindowDC();
|
|
|
|
|
|
HBITMAP hOldBmp = (HBITMAP)SelectObject(hDcWindow, data->GetWindowBmp());
|
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
if (PrintWindow(hWnd, hDcWindow, PW_RENDERFULLCONTENT) || SendMessageTimeout(hWnd, WM_PRINT,
|
|
|
|
|
|
(WPARAM)hDcWindow, PRF_CLIENT | PRF_NONCLIENT, SMTO_BLOCK, 50, NULL)) {
|
|
|
|
|
|
BitBlt(data->GetScreenDC(), rect.left - data->X(), rect.top - data->Y(),
|
|
|
|
|
|
rect.right - rect.left, rect.bottom - rect.top, hDcWindow, 0, 0, SRCCOPY);
|
|
|
|
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
}
|
|
|
|
|
|
SelectObject(hDcWindow, hOldBmp);
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int EnumWindowsTopToDown(HWND owner, WNDENUMPROC proc, LPARAM param)
|
|
|
|
|
|
{
|
|
|
|
|
|
HWND currentWindow = GetTopWindow(owner);
|
|
|
|
|
|
if (currentWindow == NULL)
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
if ((currentWindow = GetWindow(currentWindow, GW_HWNDLAST)) == NULL)
|
|
|
|
|
|
return -2;
|
|
|
|
|
|
while (proc(currentWindow, param) && (currentWindow = GetWindow(currentWindow, GW_HWNDPREV)) != NULL);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL CALLBACK EnumHwndsPrint(HWND hWnd, LPARAM lParam)
|
|
|
|
|
|
{
|
|
|
|
|
|
AUTO_TICK_C(50);
|
|
|
|
|
|
if (FALSE == PaintWindow(hWnd, (EnumHwndsPrintData*)lParam)) {
|
|
|
|
|
|
char text[_MAX_PATH] = {};
|
|
|
|
|
|
GetWindowText(hWnd, text, sizeof(text));
|
|
|
|
|
|
Mprintf("PaintWindow %s[%p] failed!!!\n", text, hWnd);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static OSVERSIONINFOA versionInfo = { sizeof(OSVERSIONINFOA) };
|
|
|
|
|
|
static BOOL result = GetVersionExA(&versionInfo);
|
|
|
|
|
|
if (versionInfo.dwMajorVersion < 6) {
|
|
|
|
|
|
DWORD style = GetWindowLongA(hWnd, GWL_EXSTYLE);
|
|
|
|
|
|
SetWindowLongA(hWnd, GWL_EXSTYLE, style | WS_EX_COMPOSITED);
|
|
|
|
|
|
EnumWindowsTopToDown(hWnd, EnumHwndsPrint, lParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2019-01-17 20:41:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-13 23:34:33 +08:00
|
|
|
|
virtual LPBYTE GetFirstScreenData(ULONG* ulFirstScreenLength);
|
2019-09-07 10:47:50 +08:00
|
|
|
|
|
2025-03-13 23:34:33 +08:00
|
|
|
|
virtual LPBYTE ScanNextScreen() {
|
2025-05-31 15:49:40 +08:00
|
|
|
|
ScanScreen(m_hDiffMemDC, m_hDeskTopDC, m_ulFullWidth, m_ulFullHeight);
|
2025-03-13 23:34:33 +08:00
|
|
|
|
return (LPBYTE)m_DiffBitmapData_Full;
|
|
|
|
|
|
}
|
2019-09-07 10:47:50 +08:00
|
|
|
|
|
2019-01-06 21:18:26 +08:00
|
|
|
|
VOID ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|