If so, how?

I would want to save it as a .jpg or .bmp

Recommended Answers

All 5 Replies

Simulate? Or capture the screen in reality using C? In either case, the answer is yes. However, doing this with a GUI vs. a text (vga) screen is a very different process. If you are running Linux, then it is simple, and you can get sample code from a number of open source sites.

Well, I said simple, but in reality it is only relatively so. How much C and graphics programming experience do you have?

I'll resist the urge to post STFW or post a Let Me Google That For You link. More details are needed, not least of which is what operating system you plan on using and what your knowledge level and skill base is.

Simulate? Or capture the screen in reality using C? In either case, the answer is yes. However, doing this with a GUI vs. a text (vga) screen is a very different process. If you are running Linux, then it is simple, and you can get sample code from a number of open source sites.

Well, I said simple, but in reality it is only relatively so. How much C and graphics programming experience do you have?

I am running Windows XP, and I am writing a program in C that needs a screenshot whenever the left mouse button is clicked:

if(GetAsyncKeyState(VK_LBUTTON) == -32767){
    // Save a picture of the screen
    // Which should be easy, in theory
}

I have plenty of C experience, I just need the libraries/functions needed to simulate a print screen. I have a wee bit of experience playing with .pgm pictures (opening, editing, and resaving), so I understand the concepts.

I'll resist the urge to post STFW or post a Let Me Google That For You link. More details are needed, not least of which is what operating system you plan on using and what your knowledge level and skill base is.

I have Windows XP, and am familiar with saving files into specific directories, and have saved image files in the past. I want to get the most cross-platform ability without coding in assembly, so I want to stick strictly to C

I've googled the shit out of different permutations of "screen shot", "print screen", "screen capture", and "in C". The best I've gotten were links to how to do it in C#. If I'm not searching correctly, let me know.

Fair enough. I apologize for the assumption. The thread just struck me as a quick post without searching the web, which of course doesn't mean you didn't search the web. When I'm wrong, I'm wrong.

As to the question itself, I'm useless in answering it. I've taken screenshots in Java, which doesn't help you in the slightest. Therefore I probably shouldn't have posted in the first place.

As to what to google, I got some decent results with "winapi c screenshot" and "c screenshot cprogramming.com". I just google till I find some codeguru, cprogramming, or stackoverflow threads, then let them take me where they take me, which is hopefully to a more specific WINAPI google search. They seem somewhat promising to a guy like me who knows next to nothing about WINAPI.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.