Author Topic: Capturing a rectangle  (Read 841 times)

shankle

  • Member
  • ****
  • Posts: 754
Capturing a rectangle
« 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.
   

Vortex

  • Member
  • *****
  • Posts: 1723
Re: Capturing a rectangle
« Reply #1 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 :

Code: [Select]
    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 :

Code: [Select]
SaveDesktop 0 0 1280 1024 Desktop.bmp
The righ lower quarter of the desktop :

Code: [Select]
SaveDesktop 640 512 640 512 Desktop2.bmp

shankle

  • Member
  • ****
  • Posts: 754
Re: Capturing a rectangle
« Reply #2 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.
 

Vortex

  • Member
  • *****
  • Posts: 1723
Re: Capturing a rectangle
« Reply #3 on: May 22, 2017, 02:45:05 AM »
Hi shankle,

Assuming that :

Code: [Select]
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 :

Code: [Select]
SaveDesktop.exe 500 600 560 650 Desktop.bmp

fearless

  • Member
  • ***
  • Posts: 279
    • LetTheLightIn
Re: Capturing a rectangle
« Reply #4 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?
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI, Samsung 256GB + 1TB SSD, WD Black 2TB x2 + 4TB HDD, Asus 27" LCD

www.LetTheLight.in  My Github

jj2007

  • Member
  • *****
  • Posts: 7730
  • Assembler is fun ;-)
    • MasmBasic
Re: Capturing a rectangle
« Reply #5 on: May 22, 2017, 03:43:37 AM »
a rectangle drawn around an external window

Something like invoke GetWindowDC, rv(GetDesktopWindow)? Won't work with the bloody Aero themes, though.

shankle

  • Member
  • ****
  • Posts: 754
Re: Capturing a rectangle
« Reply #6 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.
    

jimg

  • Member
  • **
  • Posts: 196
Re: Capturing a rectangle
« Reply #7 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.

caballero

  • Member
  • ****
  • Posts: 777
    • Abre Ojos Ensamblador
Re: Capturing a rectangle
« Reply #8 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.
En un lugar de la Mancha de cuyo nombre no quiero acordarme

shankle

  • Member
  • ****
  • Posts: 754
Re: Capturing a rectangle
« Reply #9 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.

shankle

  • Member
  • ****
  • Posts: 754
Re: Capturing a rectangle
« Reply #10 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

aw27

  • Member
  • ****
  • Posts: 852
  • Let's Make ASM Great Again!
Re: Capturing a rectangle
« Reply #11 on: July 19, 2017, 05:55:50 PM »
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

  • Regular Member
  • *
  • Posts: 1
Re: Capturing a rectangle
« Reply #12 on: December 07, 2017, 06:24:45 PM »
You can try faststone. Though I find it way too slow
json formatter and editor, 192.168.0.1 Router’s IP Address

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4922
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Capturing a rectangle
« Reply #13 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: