Capturing window display of another program?

D

David Brady

Is it possible to take a screenshot of another window in Ruby? (On Win32)

I'd like to write a script to scrape the output of a graphics test
program (which I do not have source for) at regular intervals, and run
tests against them. E.g., grab the display area & check to see if it's
generating a gradient fill (good), or a black display (bad) by testing
some of the pixels inside the display area.

What about sending clicks, drags and keypresses to that window? At that
point, it would be a poor man's WinRunner, hrm....

-dB
 
Z

Zach Dennis

David said:
Is it possible to take a screenshot of another window in Ruby? (On Win32)

I'd like to write a script to scrape the output of a graphics test
program (which I do not have source for) at regular intervals, and run
tests against them. E.g., grab the display area & check to see if it's
generating a gradient fill (good), or a black display (bad) by testing
some of the pixels inside the display area.

What about sending clicks, drags and keypresses to that window? At that
point, it would be a poor man's WinRunner, hrm....

This has to be possible, because you can do this with GIMP. Perhaps
looking into... Windows GDI and...

EnumWindows
http://msdn.microsoft.com/library/d...windowreference/windowfunctions/getwindow.asp

FindWindow
http://msdn.microsoft.com/library/d...windowreference/windowfunctions/getwindow.asp

GetWindow
http://msdn.microsoft.com/library/d...windowreference/windowfunctions/getwindow.asp

BitBlt - to perform the screenshot
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_0fzo.asp

GetWindowRect
http://msdn.microsoft.com/library/d...windowreference/windowfunctions/getwindow.asp

Good luck! Let us know when you get something working!

Zach
 
D

Dave Burt

David Brady said:
Is it possible to take a screenshot of another window in Ruby? (On Win32)

I'd like to write a script to scrape the output of a graphics test program
(which I do not have source for) at regular intervals, and run tests
against them. E.g., grab the display area & check to see if it's
generating a gradient fill (good), or a black display (bad) by testing
some of the pixels inside the display area.

What about sending clicks, drags and keypresses to that window? At that
point, it would be a poor man's WinRunner, hrm....

You can use Ruby to interface AutoIt's COM component to make this a lot
easier than using straight Windows API calls:

http://www.autoitscript.com/autoit3/
http://www.autoitscript.com/autoit3/docs/functions.htm

AutoIt is freeware and can do all these things pretty easily, including
sending clicks and keys to a window, except for taking a screenshot AFAIK,
but PixelGetColor() and PixelSearch() can be used to search for a color in a
rectangle or get the color of a pixel, so maybe that's even better for your
purposes.

Cheers,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top