News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Capturing a rectangle

Started by shankle, May 21, 2017, 09:29:11 PM

Previous topic - Next topic

shankle

                    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.
   

Vortex

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

shankle

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.

Vortex

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

fearless

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?

jj2007

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.

shankle

                      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.
    

jimg

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.

avcaballero

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.

shankle

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.

shankle

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

aw27

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.

jamesgregg

You can try faststone. Though I find it way too slow
json formatter and editor, 192.168.0.1 Router's IP Address

hutch--

Jack,

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