mnj200g has asked for the wisdom of the Perl Monks concerning the following question:

How do you minimize and maximize a unix window (such as the cmdtool window) in PERL? I am using xwd to capture the window. However, if the window is not at the top and other windows are overlayed on the window of interest, then the capture window shows the overlayed areas as junk.

Also, is there a way the just simply raise or lower the window from PERL?

Thanks for any help.

MNJ

  • Comment on Need Help: Minimize, Maximize UNIX windows

Replies are listed 'Best First'.
Re: Need Help: Minimize, Maximize UNIX windows
by samtregar (Abbot) on May 12, 2006 at 02:10 UTC
    I've used this command-line tool to automate X-windows from Perl:

    wmctrl

    -sam

Re: Need Help: Minimize, Maximize UNIX windows
by Fletch (Bishop) on May 11, 2006 at 23:45 UTC

    In general the answer is going to depend on some combination of your window manager and/or the desktop you're using. For KDE there's probably some sort of dcop incantation you can send to it, but without a bit more details you may not get anything more specific.

    And the language is Perl, the implementation is perl; "PERL" is just wrong.

    Update: Actually after thinking over it there may be some sort of window manager hints you can send, but I can't recall what you'd want to search on to track information about them down. It'd also be fairly low-level X11 calls so it wouldn't be really easy to do from perl either.

    Update 2: Yeah, that wmctl below implements the thing I was thinking about. Running that through system is going to be your best bet.

      I would look into Perl/Tk (or a different GUI toolkit) before diving into low-level X11 calls. Something about maintaining a little bit of sanity comes to mind! :-)
Re: Need Help: Minimize, Maximize UNIX windows
by arkturuz (Curate) on May 12, 2006 at 08:08 UTC
    Configure your window/desktop manager to autoraise windows. So when you want to grab a screenshot of some window it will automatically raise above other programs.

    Also, in FVWM you can make functions to grab the window automatically (after being raised) and store the image where you like it. Something similar is possible in other window/desktop managers, I suppose.

Re: Need Help: Minimize, Maximize UNIX windows
by Joost (Canon) on May 14, 2006 at 13:38 UTC
    I don't have any solution to this particular problem, but I want to caution you. Please be careful, there are a few windowmanagers around that do not allow automatic (re)sizing / "iconification" of windows at all (and for good reasons too). Like my current windowmanager - ion. Please make sure that you do not make your programs depend on the windows being a particular size, at least don't if you don't control the environment the programs are running in.

Re: Need Help: Minimize, Maximize UNIX windows
by zentara (Cardinal) on May 12, 2006 at 14:59 UTC
    I second the use of wmctrl. It also has a Perl module X11::WMCtrl

    I'm not really a human, but I play one on earth. flash japh