I am working In Progress 4GL , in my application i wish to take a screeenshot of an active window on any KeyStroke Event such as (CTRL + F9) and save the same in a prespecified folder. Can anyone Help me in this ?
Asked
Active
Viewed 504 times
0
-
This is similar to other questions asked along this line, and can be peformed using .NET: http://stackoverflow.com/questions/362986/capture-the-screen-into-a-bitmap – Tim Kuehn Dec 30 '15 at 19:55
-
Possible duplicate of [Capture the Screen into a Bitmap](http://stackoverflow.com/questions/362986/capture-the-screen-into-a-bitmap) – Tim Kuehn Dec 30 '15 at 19:56
1 Answers
0
As mentioned in the comments this can be done by calling .NET from Progress ABL. Here's an example that takes a screenshot of the entire screen. You will need to adapt this to your needs.
USING System.Drawing.*.
USING System.Drawing.Imaging.*.
USING System.Windows.Forms.Screen.
DEFINE VARIABLE bmpScreenshot AS Bitmap NO-UNDO.
DEFINE VARIABLE gfxScreenshot AS Graphics NO-UNDO.
bmpScreenshot = NEW Bitmap(Screen:PrimaryScreen:Bounds:Width,
Screen:PrimaryScreen:Bounds:Height,
PixelFormat:Format32bppArgb).
gfxScreenshot = Graphics:FromImage(bmpScreenshot).
gfxScreenshot:CopyFromScreen(Screen:PrimaryScreen:Bounds:X,
Screen:PrimaryScreen:Bounds:Y,
0,
0,
Screen:PrimaryScreen:Bounds:Size,
CopyPixelOperation:SourceCopy).
/* Use ImageFormat:[Png|Gif|Bmp|Tiff] etc for different image formats */
bmpScreenshot:SAVE("c:\temp\Screenshot.png", ImageFormat:Png).
This is a C# to ABL translation of this question on SO.