What is the best (easiest) way to take a screenshot of an running application with C++ under Windows?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
You have to get the device context of the window (
GetWindowDC()
) and copy image (BitBlt()
) from it. Depending on what else you know about the application you will use different methods to find which window's handle to pass intoGetWindowDC()
.Here is an example code
You can do
CaptureAnImage(GetDesktopWindow());
to make a screen capture.On the keybd_event function documentation it states that you can use it to take a screenshot and save it to the clipboard. For example:
In my version (Visual Studio 2005 help installed on my computer) it states that you can take a screenshot of the whole desktop by setting the second parameter to 0, or a screen shot of just the current application by setting it to 1.
Taking it out of the clipboard buffer is left as an exercise for the reader.
However I'd think carefully before doing this as it will turf whatever image data was already present in the clipboard.