Hi,

I'm trying to make a script to automate taking screenshots of dialog
boxes in Windows, and I can't get it to work quite right.

First of all some details: dialog boxes aren't "real" windows, so
WinSnap's "grab a single window" option won't work. As a workaround,
I'm capturing the whole screen and then cropping to get the dialog
box. I first crop to a certain predefined rectangle that I know
contains the dialog box over a solid background, and then autocrop to
get just the dialog box by itself. So that's no longer a problem.

Now, the most important problem I'm having is really weird: WinSnap
works just fine when I invoke it from the toolbox's File menu, but
when I try to run it from either the Script-Fu Console or my script I
get this:

ERROR: Procedural database execution failed:
   (plug_in_winsnap 0 1 1)

And here's the weird part: it spits out this error (stopping my
script) _even though the function worked!_ It took the screenshot, it
created the image, and everything would be fine if it just wouldn't
print the error.

The second problem I'm having with WinSnap is that even if you call it
with the parameter "root" set to TRUE, the dialog's option boxes still
default to "grab a single window" instead of "grab the whole screen."

The third problem is that trying to call WinSnap non-interactively (by
specifying 1 for the first parameter) causes script-fu to freeze!
Ideally, I'd like to just be able to set up the dialog I'm trying to
capture and run it from the command line (which is why the final
commented-out command in my script closes GIMP).

Anyway, the script follows. Please help me fix this!

(define (script-fu-grab-and-crop filename)

 (plug-in-winsnap 0 1 1)
 (set! image (aref (cadr (gimp-image-list)) 0))
 (gimp-image-crop image
                  800 600
                  400 105)
 (set! drawable (car (gimp-image-get-active-drawable image)))
 (plug-in-autocrop 1 image drawable)
 (set! drawable (car (gimp-image-get-active-drawable image)))
 (file-bmp-save 1 image drawable filename filename)
 ;(gimp-quit FALSE)
 )


(script-fu-register
"script-fu-grab-and-crop"
"<Toolbox>/Xtns/Script-Fu/Misc/Grab and Crop"
"Automates creating screenshots of internal windows."
"Jack Gruendler"
"copyright 2006, Jack Gruendler"
"June 22, 2006"
""
SF-VALUE "Filename:" "\"screenshot.bmp\""
)

--
Jack Gruendler <[EMAIL PROTECTED]>
"They that can give up essential liberty to purchase a little
temporary safety, deserve neither liberty nor safety."
         - Benjamin Franklin
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply via email to