#include #include int main() { INPUT inputs[2] = {{0}, {0}}; inputs[0].type = INPUT_KEYBOARD; inputs[0].ki.wVk = VK_SNAPSHOT; inputs[1] = inputs[0]; inputs[1].ki.dwFlags = KEYEVENTF_KEYUP; SendInput(2, inputs, sizeof(*inputs)); HBITMAP hScreenBitmap = NULL; do { Sleep(50); } while(!OpenClipboard(NULL)); if(IsClipboardFormatAvailable(CF_BITMAP)) { HBITMAP hTempBM = reinterpret_cast(GetClipboardData(CF_BITMAP)); if(hTempBM) { hScreenBitmap = reinterpret_cast(CopyImage(hTempBM, IMAGE_BITMAP, 0, 0, 0)); } } else { DWORD err = GetLastError(); std::cout << "clip format unavailable: " << err << '\n'; } CloseClipboard(); if(hScreenBitmap) { HDC hdc = GetDC(NULL); HDC hdcNew = CreateCompatibleDC(hdc); HGDIOBJ hOld = SelectObject(hdcNew, hScreenBitmap); BitBlt(hdc, 20, 20, 1004, 780, hdcNew, 0, 0, SRCCOPY); SelectObject(hdcNew, hOld); DeleteObject(hScreenBitmap); DeleteDC(hdcNew); ReleaseDC(NULL, hdc); } return 0; }