An alternative way to capture the screen? (C ++, Windows OS)

keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
HBITMAP h;

OpenClipboard(NULL);
h = (HBITMAP)GetClipboardData(CF_BITMAP);
CloseClipboard();
...

this usually works well. but if the foreground window changes and locks the clipboard, then it cannot open the clipboard.

Is there any alternative way to capture a screen that can work in the background?

thank,

+3
source share
2 answers

A simple screen capture scheme for monitor 1, which served me well, but does not cover all angular cases:

  • Get screen device context.
  • Create a device context that is compatible with the on-screen device context.
  • Create a device-independent bitmap (needed to obtain pixel data), the same as the screen resolution.
  • .
  • .
  • , .
  • .
  • .
+3


, ? , , .

+1

Source: https://habr.com/ru/post/1734847/


All Articles