Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!cs.utexas.edu!sun-barr!newstop!sun!frisbee!jcb From: jcb@frisbee.Sun.COM (Jim Becker) Newsgroups: comp.windows.x Subject: Re: Delayed screen snapshots Keywords: X screen snapshot Message-ID: <133176@sun.Eng.Sun.COM> Date: 20 Mar 90 19:30:28 GMT References: <312@gazette.bcm.tmc.edu> Sender: news@sun.Eng.Sun.COM Lines: 60 klong@wilkins.bcm.tmc.edu (Kevin Long) writes: I need something to take a snap shot of a region of my screen, but delay doing it for enough time for me to bring up a pop-up menu. Other ideas/suggestions? I'll repost what I learn. A bit over a year ago I needed to write a program that did this, and took a different approach than others. This program I also posted to the net, around Feb 89, and should still be around somewhere. The need was to get bitmaps of main application windows and popups to be integrated into the text/graphics help system that I developed. The approach that I took was really simple, and just a few pages of code. Here goes: 1) create a master window that defines the outline that will be snapshot. the content of this is null, just the placement and size is of interest. 2) map the window, so the user can define the area of the snapshot via window manager resize and movement. 3) run a loop that *polls* the keyboard a couple of times a second with XQueryKeymap(). 4) notice when certain non-typical keys are pressed. perform actions associated with the keys. I had front, back and snapshot bound to the physical keys. 5) when the user hits the desired key, do a XGetWindowAttributes() to synch the size and position of the master outline window on the root window. 6) save the area where the window is using the storage means of interest. at the time I saved in pixwin formats. one can also do an XGetImage() to get the bits. note that the master window should be backed before getting the image! (the image is lifted from the RootWindow) 7) have some scheme where the snapshots are numbered, and allow the user to make lots of them. I whipped up this program in a couple of hours. Not fancy but it got the job done for our tech writers to generate hundreds of screen snapshots to be integrated into the help text content. The popups that I wrote also grabbed the server, so I added a variable to the interface system that checked a global variable that toggled the server grab. (It was called `DONTGRABSERVER'!) This code should be out there on the archive servers somewhere, called snap.c. It isn't fancy, but it worked great. Something simple that gets the job done. KISS? -Jim Becker -- Jim Becker / jcb%frisbee@sun.com / Sun Microsystems