Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Start an application and set its Window Position and Size

Reply
 
Old 08-17-2008   #1 (permalink)
GrantSt


 
 

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
Old 08-17-2008   #2 (permalink)
mayayana


 
 

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

Quote:

> 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
Old 08-17-2008   #3 (permalink)
mr_unreliable


 
 

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



GrantSt wrote:
Quote:

> 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
Old 08-22-2008   #4 (permalink)
GrantSt


 
 

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
Reply

Thread Tools


Similar Threads
Thread Forum
Window Size and Position Vista General
Expand vertical size of Start window? Vista General
window position, size and views Vista General
How to keep windows size and position? Vista performance & maintenance
Desktop icons keep neither their size nor position Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46