Screenshot Browser

Oct 21, 2021 at 6:28pm
Hello,

I need to develop an application in c++ where the screenshot of a browser should be done.
Would anyone please have any examples?

Thanks.
Oct 21, 2021 at 9:42pm
Not promising to help, but what operating system?

If Windows, you need to find the handle for the window you want to take a screenshot of, figure out its dimensions to determine the size of the bitmap, then create a bitmap and fill in the bitmap.

You use Windows API calls like GetWindowRect and PrintWindow.
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowrect
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-printwindow

Here is an example:
https://stackoverflow.com/questions/7292757/how-to-get-screenshot-of-a-window-as-bitmap-object-in-c
Last edited on Oct 21, 2021 at 9:47pm
Oct 22, 2021 at 11:14am
Hi,

The operating system is Windows.
When images are displayed in a Browser, there is no concept of a window.
Any other suggestions?

Thks.

Oct 22, 2021 at 12:18pm
there must be some terminology mixup. Browsers certainly have their window when showing an image. If it has a full screen option, that is another story, are you in fullscreen? If so, get the whole screen as your capture.
screenshots of images are lower quality than just fetching the original image from the browser's cache (tricky... names are just junk) or going to the site and getting it yourself.

I think you can get the entire screen, all open programs, start menu, desktop background, etc. It gets things you don't want, but it may be easier to code.
Oct 22, 2021 at 1:44pm
Tell us exactly what you want to do, and more importantly, why. Otherwise, this smells like one of those "XY problems". Perhaps you are looking for something like wget, to download content from a webpage.
Last edited on Oct 22, 2021 at 1:45pm
Oct 22, 2021 at 4:34pm
hello,
I need to capture the image displayed in the browser in c++.

Thks.
Oct 22, 2021 at 5:45pm
There is no graphical I/O with ISO standard C++, doing what you seem to want requires a third party library.

Since you are on Windows the "best" 3rd party library is the Win API. Fair warning, what constitutes the API is a HUUUUGE undertaking. And a lot of 'net referenced material is not well documented and, well, frankly, grossly out of date with regards to the new technologies Windows has.

Doing a 'net search for "C++ windows screen capture" resulted in this metasearch:
https://duckduckgo.com/?q=c%2B%2B+windows+screen+capture&t=ffsb&ia=web

Following the MSDN link ( Screen Capture in Windows Using(C++) - https://social.msdn.microsoft.com/Forums/vstudio/en-US/32fb271c-e55f-4966-b1c4-0c26720eb8fa/screen-capture-in-windows-usingc ) there was another link at the referenced article.
https://www.codeproject.com/Articles/20367/Screen-Capture-Simple-Win32-Dialog-Based

Automating the process of screen capture is doable.
Oct 22, 2021 at 6:02pm
I would try to find a back door. All major browsers have a right click save image as functionality. If you can tap that, your work is 90% done.
Oct 22, 2021 at 6:59pm
I think OP wants the equivalent of wget, to download an image? I believe wget uses its own back-end library, but I could be mistaken (check the source).
https://www.gnu.org/software/wget/

There is also cURL, which has its own library, libcurl, which is a library for transferring files and can work over HTTP and HTTPS.
https://curl.se/libcurl/

So you'd either need to build one of these libraries yourself (probably curl), or, depending on what your needs are, you could probably get away with just invoking wget or curl from your program or from the command-line.
e.g.
Last edited on Oct 22, 2021 at 7:00pm
Oct 22, 2021 at 7:37pm
@Ganado, even if (big conjecture) the OP wants that doing so still requires a third party library.
Topic archived. No new replies allowed.