The MASM Forum

Miscellaneous => The Orphanage => Topic started by: shankle on May 21, 2017, 09:29:11 PM

Title: Capturing a rectangle
Post by: shankle on May 21, 2017, 09:29:11 PM
                    5-21-2017

    I need an API that will capture a small rectangle
    from a 3rd party screen, so that I can put it in a
    folder of my choosing.
    There are tons of other programs out there that will do
    this but they are abysmally to slow for my needs and
    they have other restrictions. EX: FastStone Capture
    and the Snipping Tool.
    Use of the Clipboard also makes the speed I need to slow.
    Thanks for any help.
   
Title: Re: Capturing a rectangle
Post by: Vortex on May 22, 2017, 01:31:12 AM
Hi shankle,

There is no any specific API to capture a portion of the screen. I modified my desktop capturing tool and  here is my function :

    invoke  SaveDeskToFile,sx,\ ;x-coordinate, in logical units, of the upper-left corner
                           sy,\ ;y-coordinate, in logical units, of the upper-left corner
                           x,\ ; width, in logical units, of the rectange to capture
                           y,\ ; height, in logical units, of the rectange to capture
                           fname ; file name of the bitmap to save


For example, if you wish to capture the full desktop with SaveDeskop.exe assuming that your screen resolution is 1280X1024 :

SaveDesktop 0 0 1280 1024 Desktop.bmp

The righ lower quarter of the desktop :

SaveDesktop 640 512 640 512 Desktop2.bmp
Title: Re: Capturing a rectangle
Post by: shankle on May 22, 2017, 02:33:17 AM
Thank you Vortex.
Makes one wonder how all these 3rd parties get the portion of the screen that is asked for.
I thought there was an API to handle it.

I need a small portion of the screen in the middle of the screen.
Not having played with your example yet, I don't see how it would address a rectangle at
500x and 600y  by 560x and 650y.
Title: Re: Capturing a rectangle
Post by: Vortex on May 22, 2017, 02:45:05 AM
Hi shankle,

Assuming that :

x-coordinate, in logical units, of the upper-left corner = 500
y-coordinate, in logical units, of the upper-left corner = 600
width, in logical units, of the rectange to capture      = 560
height, in logical units, of the rectange to capture     = 650


The command-line should be :

SaveDesktop.exe 500 600 560 650 Desktop.bmp
Title: Re: Capturing a rectangle
Post by: fearless on May 22, 2017, 03:31:41 AM
In relation to this topic, anyone know how to have a rectangle drawn around an external window that you want to capture - similar to a lot of spy++, WinID, Inspect tools, that show the window region with a red rectangle for the window that the tool is interested in?
Title: Re: Capturing a rectangle
Post by: jj2007 on May 22, 2017, 03:43:37 AM
Quote from: fearless on May 22, 2017, 03:31:41 AMa rectangle drawn around an external window

Something like invoke GetWindowDC, rv(GetDesktopWindow)? Won't work with the bloody Aero themes, though.
Title: Re: Capturing a rectangle
Post by: shankle on June 22, 2017, 09:41:20 AM
                      6-21-2017

HI Vortex
Thank you for the example program you put in this thread.
It does not do what I need and I have also tried a GDI example.
Faststone Capture and the Windows 7 Snipping Tool are way to slow
for the use I need.

This program is for my use only. Being an old guy(bad memory)  I am
trying to save the cards played and filling in the boxes in the display shown.
I have no control over the program that I am taking this data from.
I need to copy a small rectangle from the center of the screen.
I have about 3 to 4 seconds to get the data and process it from
trick to trick. So sending the data to a file or clip board is way
to slow.
From my trials I would say that there might be a focus problem OR
if I should use WM_LBUTTONDOWN/UP or WM_KEYDOWN/UP.
There are many mouse pushes before I select the data from the 3rd party
program the first time. Then I select the data to send to my program
for processing. Then I need to process the data in my program and go back
to the 3rd party program for the next trick data.
I'll give a sample in brief of the rectangle that receives the data, as the rectangle
is to large to add as an attachment. This is all in a rectangle over the 3rd party screen.
        AKQJ198765432
      S   The cards played are blacked out here.
      H
      D
      C

         The Data from the 3rd party screen goes here.
    
Title: Re: Capturing a rectangle
Post by: jimg on June 22, 2017, 10:37:57 AM
Have you tried MWSnap?  You can set up an area to capture with ctrl-shift-a, and to capture that area of the screen again just hit ctrl-shift-L.  It doesn't automatically save, but you can save with ctrl-s, type a quick name and hit return.   Once get in a rhythm, you can save every few seconds.
Title: Re: Capturing a rectangle
Post by: avcaballero on June 22, 2017, 08:41:14 PM
I use faststone and I'm very happy with it. Maybe what you need is to record a video, not regular shots. Once you have finished you can save it as a file.
Title: Re: Capturing a rectangle
Post by: shankle on June 22, 2017, 10:19:00 PM
Thanks guys for replying.
I also like Faststone but it is way to slow for what I need.
I need the info as it comes in to know what I can play next.
A video won't help with that.
I will give MWSnap a shot. Most likely it will be to slow for what I need.

Faststone puts a red rectangle around the info I need to capture.
That is just the kind of thing I need but stubbornly will only put
it to the clipboard. Way to slow.
Title: Re: Capturing a rectangle
Post by: shankle on July 11, 2017, 12:31:06 AM
Anyone know how to code the EnumWindows function and the EnumWindowsProc
callback function. Think this might work for what Iam trying to do.
I don't understand the APi listing of the above functions so an example is what
I need. Thanks
Title: Re: Capturing a rectangle
Post by: aw27 on July 19, 2017, 05:55:50 PM
Quote from: shankle on July 11, 2017, 12:31:06 AM
Anyone know how to code the EnumWindows function and the EnumWindowsProc
callback function. Think this might work for what Iam trying to do.
I don't understand the APi listing of the above functions so an example is what
I need. Thanks

All screen capture outside the current application is normally done with BitBlt or other variations like StrecthBlt. You can also do it with DirectX.
You will find examples in many places.
With BitBlt is pretty simple, I will do an example if you are stuck but I am pretty busy now.
Title: Re: Capturing a rectangle
Post by: jamesgregg on December 07, 2017, 06:24:45 PM
You can try faststone. Though I find it way too slow
Title: Re: Capturing a rectangle
Post by: hutch-- on December 07, 2017, 07:01:14 PM
Jack,

This one comes at the right price and seems to do screen grabs of your choice with no problems.