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

Hi

I wonder if windows knows something corresponding to "geometry" like in X to script at startup of an application where the window should be placed ... couldn't google any batch script for doing this.

While I'm sure that it's possible after installing Windows Scripting Host, I'd rather prefer to do it with perl, so whats the way to go?

Hope there is something more straightforward than manipulating the registry entry of the last geometry...

Cheers Rolf

Replies are listed 'Best First'.
Re: positioning and sizing windows in XP
by BrowserUk (Patriarch) on Feb 14, 2010 at 05:57 UTC

    CreateProcess allows this via the lpStartupInfo parameter. Unfortunately, Win32::Process does not give access to that structure.

    It would probably be a relatively trivial to add a second constructor to the class definition that underlies that module, to take a hash to fill in the structures values, but that may be further than you wish to go.

    You might also be able to use Win32::GuiTest to reposition the window once it has been created. But that process would be visible to the user, and given you won't know the original position, would require a bit of thought to make work reliably. Modifying Win32::Process is probably easier.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: positioning and sizing windows in XP
by Khen1950fx (Canon) on Feb 13, 2010 at 23:56 UTC
      Maybe I'm blind but from the docs this rather looks like a cheap alternative for TK.

      I need to control the size and position of an application like e.g. Solitair, this as easy as possible.

      But thanx I'm gonna browse the Win32:: namespace of CPAN :)

      Cheers Rolf

Re: positioning and sizing windows in XP
by zentara (Cardinal) on Feb 14, 2010 at 16:02 UTC
        Just to broaden your horizons, to see how we do it on linux, see wmctrl and a perl module for X11 sysytems X11::Wmctrl

        You might want to ask around MSwindows groups about a wmctrl-like utility for win32.

        I only mention this, in case your desire is to size windows for existing apps, like start up with position-size = (+100+100+640x480)

        I would guess Microsoft puts entries somewhere in the registry. You can google for "microsoft window sizes" to get some leads.


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku