cancel
Showing results for 
Search instead for 
Did you mean: 

Saving an image in clipboard as an image file

tauseef_khan
Level 3
I have taken a screenshot of my desktop using the keyboard shortcut (ALT + PRTSC). Now I want to save the screenshot as an image file without using any other programs (e.g. paint) to a location on the hard drive (it doesn't really matter where). Is this possible?
4 REPLIES 4

Denis__Dennehy
Level 15
This is possible using a code stage, maybe contact your main Blue Prism consultant contact for such screenshot code. One thing to be careful of if you intend to do this in production is the Security Policy in place for your Blue Prism solution. Screenshots could contain customer data, so the storage of such data outside the secure Blue Prism solution (i.e. such as in a shared network drive) is likely to not adhere to policy.

BuzzaT
Level 4
Came to this forum looking for exactly this issue. Currently, I have a process that captures the environment and loads it into a Blue Prism image data type. Unfortunately, the whole process involves taking a screen cap similar to the starting post, and then popping open Paint, Pasting it, and then copying that image to the paint canvas. From there I am saving the visual region in paint either as BP Img data or a .png file. A curious thing is that you can actually hook BP right into the underlying Windows OS and take a 'region' cap of the desktop. Unfortunately, you get exactly that, the desktop without of the overlaying windows even if they're open. I was about to take a stab at it via some VB coding, but I was hoping to find a simple solution first. I wanted to add that the Post by Denis raises a good issue, but so long as the file stays Internal as a Blue Prism Img data type, it's not readily publishable as a Windows System level data item, and might be viewed 'differently' for security reasons. Just a thought. I'm sure I can get the screen cap into a VB image type, transitioning it to a BP 'Img' data type is really the only hiccup at this point. Here's to hoping one of the minds at BP reads this thread. -Tyler

BuzzaT
Level 4
Update: Got it. Here's the VB code that will dump your clipboard to a VB object. (getting the image to the clipboard is up to you, but I think you solved that already) This hasn't been refined, but it works. With a code stage where Img_Out is a BP Image type Output, and also saves it to a directory of your choice. I put in a commented out version of saving as 'bmp' as an option as well. Luckily, the data types copy right over to the BP Image format with their overloaded '=' operator, unless they're using the built in bitmat type as the Image data anyways. Dim oDataObj As IDataObject = System.Windows.Forms.Clipboard.GetDataObject() If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then Dim oImgObj As System.Drawing.Image = oDataObj.GetData(DataFormats.Bitmap, True) 'BMP Format 'oImgObj.Save(""\\YourServer\BluePrism\Output_Directory\Test.bmp"", System.Drawing.Imaging.ImageFormat.Bmp) 'PNG Format oImgObj.Save(""\\YourServer\BluePrism\Output_Directory\Test.png"", System.Drawing.Imaging.ImageFormat.Png) Img_Out = oImgObj End If

tauseef_khan
Level 3
Thank you Denis and BuzzaT, both of you have given me some useful points to think about and a working solution. I never thought about the security issue so I'm glad I asked in the first place as I can consider it for this automation as well as future ones.