Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Automatic Screenshot And Clipboard Reader

Recommended Posts

I am having a problem with a windows console application on an NMR imaging instrument. The software is a console that takes control of the user?s screen. The problem is that the saving of the data we need causes crashes commonly. The program is not open source and specific to the scanner. I cannot replace the computer or change the operating system ? it is an instrument used by others too who do not use the same imaging technique that I do. What works is taking screenshots every so many seconds and processing them, although this is a horrible time consuming method. I already have written a converter that reads the part of a BMP which contains data and convert to a workable format and store it in a separate file.What I think will work is the following:Automatically make a screenshot just as if the key has been pressed every so many secondsAccess the image in the clipboard (.BMP I suppose, hence the data is accessible easily)Append to file (I already have the code that will do this)However, I do not use windows so much and have no idea how to make screenshots from software and access the clipboard other than pressing ctrl-v in the paint program. Can anyone help me out here?

Share this post


Link to post
Share on other sites

Firstly, it always helps to search the MSDN documentation for stuff like this. You would need to use Windows-specific commands (probably) to access the clipboard and take screenshots.

The way I'd do it is:
1) simulate a PrintScreen keypress (I'm pretty sure you could do this with the SendMessage() Function; send the WM_KEYDOWN Message with VK_SNAPSHOT as a parameter).
If you wanted to find other Key Codes for any other steps, the MSDN library has an article titled 'Virtual-Key Codes' which has every code listed.

2) Use the Clipboard Win32 function/message set (MSDN article here: http://forums.xisto.com/no_longer_exists/) to retrieve the data.

The MSDN library has info on it all. You can easily find the articles in step 1 by simply searching for furthur reference.

Good Luck mate! :)

Share this post


Link to post
Share on other sites

There is an API i think in order to get a screenshot of the screen. Check MSDN (https://msdn.microsoft.com/en-us/default.aspx) for the specific API and its usage. I wrote something like this a while ago to capture screenshots while playing a game and save them into a file in a directory. It will be a lot easier to create a new file or overwrite the old file instead of appending to it, because you would have to increase the size of the image.

Share this post


Link to post
Share on other sites
Replying to kvarnerexpress

I'm not sure if this is exactly what you need, but I've had great success with AutoScreen. It allows for saving of the screenshot in many different image formats (including BMP, which you wanted).

I don't think simulating a PrintScreen keypress would be a good idea, because that would cause any data in the clipboard to be lost; this could of course be fixed by saving the data before you send the keypress, and then restoring it, but this could be inefficient, and there's always the possibility of a race condition (user tries to paste something they copied to the clipboard at the exact moment the clipboard data was temporarily replaced with a screenshot after simulating a PrintScreen keypress).

-reply by jjnak

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.