RSS/Atom feed Twitter
Site is read-only, email is disabled

Using plug-in-winsnap in script

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

Using plug-in-winsnap in script Jack Gruendler 22 Jun 19:35
  Using plug-in-winsnap in script Sven Neumann 22 Jun 20:00
Jack Gruendler
2006-06-22 19:35:52 UTC (almost 18 years ago)

Using plug-in-winsnap in script

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"
"/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\"" )

Sven Neumann
2006-06-22 20:00:02 UTC (almost 18 years ago)

Using plug-in-winsnap in script

Hi,

The winsnap plug-in is obviously broken. The best thing you can do is to get the source code and fix it, then submit a patch with the fix. Or wait, there's something even better you can do: Add the missing function to the screenshot plug-in in CVS that keeps it from working on the Windows platform. We could then finally get rid of the winsnap plug-in which has been sitting unmaintained in the source tree for several years now, waiting to be replaced by the supposedly platform-neutral screenshot plug-in.

Sven