Windows Vista Forums

Start an application and set its Window Position and Size
  1. #1


    GrantSt Guest

    Start an application and set its Window Position and Size

    I regularly load a program which defaults to being full screen and also never
    remembers it's previous size or position. Therefore I've created a VBScript
    that loads the program and sends a key to restore the window from being
    maximised.

    How do I also set the size and position of the window?

    The script I'm currently using is:
    dim GuitarProPath
    GuitarProPath = """C:\Program Files\Guitar Pro 5\GP5.exe"""
    set Shell = WScript.CreateObject("WScript.Shell")
    shell.run GuitarProPath
    wscript.sleep(2000)
    shell.sendkeys "% r" '...restore



    Thanks for any help,
    Grant

      My System SpecsSystem Spec

  2. #2


    mayayana Guest

    Re: Start an application and set its Window Position and Size


    > How do I also set the size and position of the window?
    >
    You can't do that unless the program provides some
    kind of command line option for it. Those details are
    controlled internally.





      My System SpecsSystem Spec

  3. #3


    mr_unreliable Guest

    Re: Start an application and set its Window Position and Size



    GrantSt wrote:

    > How do I also set the size and position of the window?
    >
    There are two possibilities.

    1. If you don't mind using a 3rd-party control, then
    try autoitX.

    2. There is also a "pure" script method, which can cause
    a great deal for angst, but may get the job done.

    If the app has a "system menu" (commonly if an app has a
    logo icon in the its window's upper left corner, then it
    supports a system menu). First appactivate the window
    you wish to move/size. Then using sendkeys, sent an
    alt-space combination to bring up the system menu.

    Then for move send alt-m, for size send alt-s. If using
    sendkeys, this may be alt-space-m, or alt-space-s.

    For either move or size the frame of the window will show
    a wide gray border.

    For move, send a down or up arrow to more the window down
    or up, and send a left or right arrow to move the window
    left or right. Send a cr to stop this.

    For size, you should see a "four Arrow icon" (a.k.a. a
    N-E-S-W icon) in the center of your (active) window. Then
    if you send an up arrow, you will see a N-S arrow appear
    on the top border, sending a down arrow will give you a N-S
    arrow on your bottom border. Then you can move the top or
    bottom of the window with up or down arrows. Send a cr to
    stop this. Likewise, starting with the NESW cursor, you can
    send a left arrow to move the left border and a right arrow
    to move the right border.

    This is more easily done from the keyboard, but you may also
    (after using plenty of enabling profanity) be able to eventually
    achieve this from script.

    cheers, jw
    ____________________________________________________________

    You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
    the answers will be applicable to the questions)

      My System SpecsSystem Spec

  4. #4


    GrantSt Guest

    Re: Start an application and set its Window Position and Size

    Hi,

    Thanks for the reply, I would have got back sooner but for some reason I
    didn't get a notification email. I already have a program called Girder that
    I've used previously for sending window messages when remote control signals
    are received. So while I've managed to set it up to restore, move and size
    the window, in response to a pressing specific keys. that program doesn't
    seem to have any kind of ordering or delay facilities so I can't use it to
    load the program and then set the size.

    I guess I was wondering if there was a way of using VBScript to size and
    position windows the same way third party programs do.

    Anyway I'm going to look into using autoitX or a similar program.

    Thanks,
    Grant

      My System SpecsSystem Spec

Start an application and set its Window Position and Size problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Window Size and Position Stray_Mongrel Vista General 3 30 Nov 2008
Expand vertical size of Start window? Robert M. Lincoln Vista General 0 22 Jun 2008
window position, size and views Glenn Vista General 3 09 Feb 2008
How to keep windows size and position? beto666 Vista performance & maintenance 0 23 May 2007
Desktop icons keep neither their size nor position Kai-Uwe v. d. Ohe Vista General 4 19 Sep 2006