开发者

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_KE开发者_StackOverflow社区YUP, 0);
HBITMAP h;

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

normally this works well. but if the foreground window changes and locks the clipboard then it can't open clipboard.

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

thanks,


A simple scheme to capture the screen of monitor 1, that served me well but doesn't cover all corner cases:

  1. Get the screen device context.
  2. Create a device context compatible with the screen device context.
  3. Create a device independent bitmap (needed to get at the pixel data) that is as large as the screen resolution.
  4. Select the device independent bitmap into the compatible device context.
  5. Bit blit the screen device context onto the compatible device context.
  6. Deselect the device independent bitmap.
  7. The image data is now in the device independent bitmap.
  8. Optionally write the image data to file.


Capturing an Image
Could this be what you are looking for? What the example does is basically take a printscreen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜