From: Zach Dennis Date: 2005-07-15T14:16:00+09:00 Subject: Re: Capturing window display of another program? David Brady wrote: > 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/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/getwindow.asp FindWindow http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/getwindow.asp GetWindow http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/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/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/getwindow.asp Good luck! Let us know when you get something working! Zach