PDA

View Full Version : Window Capture Library


sside
09-06-2006, 11:16 AM
Hello everybody

Window capture library will capture any window that is visible by providing the window handle.

Functions:

CaptureWindow // Capture window by specifying the window handle. Returns image filename.
GetError // Get error.

Here (http://ams5.ssideproject.com/downloads/WindowCapture.v.1.0.0.0.apz) you can download the ams5 project.

.Net 2.0 required.


With Kind Regards

sside

sside
09-06-2006, 12:48 PM
Functions:

CaptureWindow //Capture window by specifying a window handle. Will return the filename of the saved image file (jpeg format).
CaptureWindowEx //Capture window by specifying window handle and a filename+imageformat. Formats supported: bmp, gif, jpeg, png.
GetError // Get errors.

The captured window will be saved as jpeg (standard by using CaptureWindow) or at your chosen format (by using CaptureWindowEx)

Here (http://ams5.ssideproject.com/downloads/WindowCapture.v.1.0.0.1.apz) you can download ams5 project.

With Kind Regards

sside

sside
04-10-2007, 05:50 PM
Functions:
GetFileName
SetFileName //Set filename before capturing. If for example the filename is c:\image.jpeg the sequential captured images will be c:\image1.jpeg, c:\image2.jpeg etc etc.
GetImageFile //Images are saved at the given location (SetFileName) but also in an inner list. GetImageFile retrives the image filename in that lists and removes it from the list.
CaptureFromHwnd //Capture window from window handle.
CaptureRectangle //Capture any part of the screen by providing the rectangle (x, y, width, height).
CaptureScreen //Capture all screen.
CaptureWindow //Shows an movable, sizable capture "window" (window border to be exactly). Click ctrl+c while the window has focus to capture.
CaptureStart //Dynamic capture mode. Every window upon which the mouse rests/hoovers/moves will be visibly highlighted and surrounded with a green border. The highlighted window is a target to be captured. Press ctrl+c to capture.
CaptureStop //Stop dynamic capture mode.
GetError

Formats supported are:
Bmp
Gif
Jpeg
Png

To edit captured images or to print the visit this post:
http://indigorose.com/forums/showthread.php?t=18217 (ImageEdit.dll, Print.dll).

Download:
WindowCapture.v.1.0.0.3.apz (http://ams5.ssideproject.com/downloads/WindowCapture.v.1.0.0.3.apz)

.Net 2.0 required.

With Kind Regards
sside

sside
10-13-2007, 08:19 AM
Functions:

GetFileName
SetFileName
GetImageFile
CaptureFromHwnd
CaptureRectangle
CaptureScreen
CaptureWindowOpen
CaptureWindowClose
CaptureHighlightedWindowStart
CaptureHighlightedWindowStop
CaptureFromPrtScrStart
CaptureFromPrtScrStop
GetError

.Net 2.0 required.

With Kind Regards
sside

S0mbre
02-27-2008, 11:56 PM
Tried to use the function for Rectangle Capture, but it just doesn't work. :huh I do have .NET 2.0 SP1, and somehow the DLL can't load the captured image (if it captures it at all). I even tried to replace your ".jpeg" extention by the standard ".jpg", but it didn't work. BTW, where are the images saved to? I mean, the function returns just a string like "Image1.jpeg", "Image2.jpeg" etc, but how do I know where to take the captures from?

Here's my piece of code:

----------------------------------------------------------------------------
rawfile = WindowCapture.CaptureRectangle(12, 12, 101, 79); -- return DLL.CallFunction("AutoPlay\\Docs\\WindowCapture.dll", "CaptureRectangle", x..","..y..","..width..","..height, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL)
Image.Load("The_Image", AmendRaw(rawfile));

-- IN GLOBALS --

function AmendRaw(rawfile)

fileName_t = String.SplitPath(rawfile);
fileName_e = fileName_t.Filename;
fileName_new = fileName_e..".jpg";

return fileName_new

end
----------------------------------------------------------------------------

Thank you!

sside
02-28-2008, 01:01 PM
Are you having touble with the uploaded project (WindowCapture.v.1.0.0.4.apz) or have you modified the code and it doesn't work as expected?

Try this:


fileName = WindowCapture.CaptureRectangle(0, 0, 400, 300);
Image.Load("Image1", fileName);


The images are saved at temp folder.

The code at globals doesn't make any sense. You are modifying a string and not the filename. If you are trying to move or to rename the image file use File.Copy, File.Move, File.Rename etc.

CaptureFromHwnd, CaptureRectangle, CaptureScreen will return the captured image filename. These functions are straight forward. Just load the image filename that the functions return in a image object and that's it.

CaptureWindowOpen, CaptureHighlightedWindowStart, CaptureFromPrtScrStart will return nothing because need user interaction. You must specify an image filename first using SetFileName. If you specify image.jpeg as file name the captured image will be saved as jpeg. But if you specify image.png as filename the captured image will be saved as png. Formats supported are: bmp, gif, jpeg, png. The captured image will be stored in an internal list. Use GetImageFile to get the captured image file.

When using SetFileName specify the full path + filename.


SetFileName("C:\\Images\\image.jpg");


You must take a look at the project that i have uploaded (WindowCapture.v.1.0.0.4.apz). It should be clear.

With Kind Regards
sside

S0mbre
02-29-2008, 05:50 AM
sside, I am sorry to say, the DLL doesn't seem to capture anything. I've been using the simple code:

fName = WindowCapture.CaptureRectangle(10, 10, 100, 100);
Image.Load("Pic_1", fName);

...but could never see the capture shot inside "Pic_1". Can you tell me the folder name where the function saves the captured files to?

sside
02-29-2008, 10:51 AM
Few questions:

What is your os?
The dll call is the return type set to DLL_RETURN_TYPE_STRING?
What is the dll call, is it DLL_CALL_STDCALL or something else?
What do you see if you do this?

fileName = WindowCapture.CaptureRectangle(0, 0, 400, 300);
Dialog.Message("FileName", fileName, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

Do you have any problem with the rest of the functions?
Can you test it at another computer where .net 2.0 (without sp1) is installed?
Can you post a simple project (.apz) that i can test it?

The files are saved in the temp folder.
It is tested in win xp pro and vista.

With Kind Regards
sside

S0mbre
02-29-2008, 09:44 PM
1. OS is Win XP Professional SP2

2. The DLL code is yours:


function WindowCapture.CaptureRectangle(x, y, width, height)
return DLL.CallFunction("AutoPlay\\Docs\\WindowCapture.dll", "CaptureRectangle", x..","..y..","..width..","..height, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
end


3. If you try to Dialog.Message the return string, it comes up with nothing, i.e. empty string.

4. Of all the functions only the "From HWND", and "Screen" seem to work. In the APZ you included with your post, the "Rectangle" function indeed comes up with the new capture filename like "Image1", "Image2" etc. but doesn't load the captured image into the form.

Maybe the temp folder on my computer is different?

My sample: 5988

Thank you!

sside
03-01-2008, 02:44 AM
My bad. It was long time ago i wrote this dll and i had to open the project files to refresh my memory.

The above explanation needs a little bit correction.

Form this:

fileName = WindowCapture.CaptureRectangle(0, 0, 400, 300);
Image.Load("Image1", fileName);


to this:

WindowCapture.SetFileName("c:\\image.jpg");
fileName = WindowCapture.CaptureRectangle(0, 0, 400, 300);
Image.Load("Image1", fileName);


If you use:

WindowCapture.SetFileName("image.jpg");

the image will be saved where the exe is.

Again, the uploaded example (WindowCapture.v.1.0.0.4.apz) should work as expected. You can see that on Page OnShow SetFileName is the first function being called.

With Kind Regards
sside

S0mbre
03-01-2008, 10:01 AM
Thank you! I was actually thinking (intuitively) of placing SetFileName before the capture function, but you are just quicker with the reply! :yes

sside
09-21-2008, 08:11 AM
Functions:

CaptureFromHwnd
CaptureRectangle
CaptureScreen
CaptureFromProcessId
CaptureFromProcessName
CaptureWindowOpen
CaptureWindowClose
CaptureHighlightedWindowStart
CaptureHighlightedWindowStop
CaptureFromPrtScrStart
CaptureFromPrtScrStop
GetImageCount
SaveImage
GetError

New:

CaptureFromProcessId
CaptureFromProcessName
GetImageCount
SaveImage

Note:
The .dll keeps the captured images in an internal queue (memory). Use GetImageCount to get the captured image nr. Use SaveImage to save the image (you can specify filename and format). Formats supported: bmp, gif, jpeg, png, tif.

.Net 2.0 required.

With Kind Regards
sside

Dermot
09-21-2008, 10:49 AM
Very nice additions. Thank you.

jassing
02-24-2010, 02:37 PM
when I specify a path for saveimage -- it doesn't save and no error is generated.

is there a way to specify a path for the save image?

jassing
02-24-2010, 03:16 PM
As near as I can tell, it is working -- except that it keeps a file handle open for some reason -- at least on vista... Moving on to other methods....