The clipboard is a handy little helper. Once you've learned to harness the power of the PRINT SCREEN key (in combination with the Alt modifier), you probably don't want to let it go. It's often just a very handy feature to be able to pull a hard-copy of something you see, be it in a video (if shots to clipboard work with it), for documentation -- or when you're in a video conference and catch somebody poking his nose (or he's presenting his desktop and his fling pops up with a Skype message, etc). I wrote a little program to be more efficient when taking them.

The problem

Using only the tools coming with windows, my workflow was something like this:

When short on time, the save step can be delayed -- instead I openend just additional instances of MS Paint for each screenshot. So in the end of the day, I pay for timely shortness by the memory overhead of one MS Paint instance per screenshot. Meh.

The solution

The solution is as easy as it seems -- just have some program sitting in the background which checks whether there's a new picture in the clipboard, and if so, dump it to a file at a defined location. There are two ways of noticing a changed clipboard content -- either polling for whether the contents changed or getting a notification. The notification would need some registering and hooking and passing the notification forward. Compare that to polling, which essentially is having a timer and checking repeatedly whether the hDC for the picture in the clipboard has changed. Facing the decision between timer and integer comparison and some mumbo jumbo API calls (which aren't that big of a deal either, granted; but still some LOC more I can screw up) I sure went for polling.

So in the end, there's this: A little program which -- as soon as a target directory is available -- will check every 10 ms whether the current hDC handle for the picture in the clipboard has changed. If so, dump a copy of the new picture. That's all.

License and Code

Ever since I got my Delphi 4 back to running on Windows 7, the program is written in some ten lines of Object Pascal and are hereby released under BSD license. Feel free, but don't complain.
Just a binary: down/cbrdi.exe.zip, Source w/o binary: down/cbrdi-src.zip
SHA256 (cbrdi-src.zip) = 50437a26cd98b6b88bcbba357923bf0573ea9f5d1132b53479b2a403f98ffaf0
SHA256 (cbrdi.exe.zip) = 99a5c9f63048223ffddf1f69c79659faf482d25aceb4adf8751395de2d7ef507
MD5 (cbrdi-src.zip) = 4cdf41aa6487924c7620f0c51557bc14
MD5 (cbrdi.exe.zip) = 938a72e4725828a143919bc21f3724ec
Note: I do not recommend the execution of binary files downloaded from the Internet. Read, understand and then compile it yourself. Maybe working with fpc/lazarus, may not.

Stichworte:


Impressum