Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Start an application and set its Window Position and Size

1,795 views
Skip to first unread message

GrantSt

unread,
Aug 17, 2008, 5:06:02 AM8/17/08
to
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

mayayana

unread,
Aug 17, 2008, 10:43:33 AM8/17/08
to

> 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.


mr_unreliable

unread,
Aug 17, 2008, 5:40:37 PM8/17/08
to

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)

GrantSt

unread,
Aug 22, 2008, 9:02:01 AM8/22/08
to
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

0 new messages