How does the "print screen" function work?

1

I've tried to research this myself but I haven't been able find an answer. I'm specifically interested in the sequences of functions that allow it to happen, if possible and relevent, with the files/script(s) executed in the process. Such as, this happens, then that happens etc, as specific as possible.

Also, if a print screen is able to be "pasted" then it must have a temporary file somewhere that saves it before it's overwritten by the next thing that's copied, would you also be able to tell me the location of this file? And, how is it even able to be pasted, does the OS copy the image after it's saved in a location?

I'm interested in information specifically regarding Windows 10 (current or any recent edition), however if you have the knowledge I will be interested in knowing how it works on other Operating Systems too.

Edit: A user in the comments posted these two links to provide the programming background:

It would be great if someone could explain how they... work... in plain english though ;)

scooptywoopty

Posted 2019-11-24T05:54:58.310

Reputation: 11

1very interesting stuff, thank you. Though since I don't have any programming knowledge beyond Mark-up, it would be great if someone could explain how it works - I'm going to add the links you posted to the question. – scooptywoopty – 2019-11-24T06:10:47.657

My knowledge of this is Windows only. The "print screen" function copies screen contents to the clipboard. The clipboard is not a file and the function does not use any scripts. Everything is done with Windows system functions. Describing this to someone with limited programming knowledge is not simple and I would not care to try. – LMiller7 – 2019-11-25T02:36:51.333

Why did you comment then? Clipboard was used metaphorically since Windows 10 doesn't have built-in clipboard functionality afaik. Perhaps, if you are confident about your knowledge then try this: open the snipping tool, snip something random and don't save it, then minimise the window and take a print screen using "ctrl + prtsc" - now try and paste that print screen. You don't get the print screen, you get the image of the thing you "snipped" even though you didn't actually copy it; this is reason i'm asking. Multiple others also get the same result. @LMiller7 – scooptywoopty – 2019-11-25T03:25:29.387

Just realised that it does have a clipboard now ^ – scooptywoopty – 2019-11-25T03:31:02.270

Answers

0

I'm specifically interested in the sequences of functions that allow [the "print screen" function work].

Any given program (whether the OS itself or a third-party application) likely uses the appropriate OS functions/API calls as mentioned in the comments. So the general steps in capturing and pasting a screenshot would be:

  • Call the appropriate function(s) to copy the memory containing the current screen image data to the clipboard.

  • Call the appropriate function(s) to copy the current data (screen image) from the clipboard and output it in an appropriate format for a program or as a file.

This happens, then that happens etc, as specific as possible.

Note that quoting any actual "functions" used is likely irrelevant in the sense that the specific functions you call to manage the screenshots and/or clipboard are different for both different operating systems as well as programming languages (even though they do the same general things). You would likely need to pick an OS and language for this to be meaningful.

If a print screen is able to be "pasted" then it must have a temporary file somewhere that saves it before it's overwritten by the next thing that's copied[.]

The "temporary file" you are referencing is likely unnamed and kept solely in RAM under the computer clipboard.

Open the Windows Snipping Tool, snip something random and don't save it. Then minimize the window and take a print screen using CTRL + PrintScreen. Now try and paste that print screen. You don't get the print screen, you get the image of the thing you "snipped" even though you didn't actually copy it."

This behavior seems (possibly) specific to the Snipping Tool and CTRL + PrintScreen. Under Windows 7, I can reproduce this behavior but using PrintScreen works normally under these circumstances (as does ALT + PrintScreen).

Anaksunaman

Posted 2019-11-24T05:54:58.310

Reputation: 9 278