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

How to make program window go from minimized to Maximized with vbscript

1,493 views
Skip to first unread message

Kevin

unread,
Jul 22, 2004, 10:01:09 AM7/22/04
to
I have a program that needs to run in the backround on a server 24/7 for
sales order processing. I need to set the program's user date each night.
I have a vbscript that runs in the scheduled tasks to do this. The script
checks to see if the program is active and if it is it performs a F9
sendkey. This works only if the target program is not minimized. If the
window is in normal or max mode I guess, it works just fine. How can I
modify this vbscript to force the program to display it's window full screen
before I send the F9 key? I'me familiar with coding in VB6 but not
vbscript! I'm running a Windows XP PC application.

Thanks!

Keivn
==============

dim WshShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
returnValue = WshShell.AppActivate( "Program Window Name")
' seems as right here I need code to force the program window to normal or
max before sendig the F9 keystroke.

If returnValue = true then
WshShell.sendkeys "{F9}"
Wscript.sleep (1000)
wshShell.sendkeys "{ENTER}"
End if

Set WshShell = Nothing


thunder2232

unread,
Jul 22, 2004, 12:25:55 PM7/22/04
to
No promises but take a look at the additions to your script that I added below...

"Kevin" wrote:

> I have a program that needs to run in the backround on a server 24/7 for
> sales order processing. I need to set the program's user date each night.
> I have a vbscript that runs in the scheduled tasks to do this. The script
> checks to see if the program is active and if it is it performs a F9
> sendkey. This works only if the target program is not minimized. If the
> window is in normal or max mode I guess, it works just fine. How can I
> modify this vbscript to force the program to display it's window full screen
> before I send the F9 key? I'me familiar with coding in VB6 but not
> vbscript! I'm running a Windows XP PC application.
>
> Thanks!
>
> Keivn
> ==============
>

Const MAXIMIZE_WINDOW = 3


> dim WshShell
> Set WSHShell = WScript.CreateObject("WScript.Shell")

> returnValue = WshShell.AppActivate( "Program Window Name"), MAXIMIZE_WINDOW 'This should be on one line with AppActivate.

Torgeir Bakken (MVP)

unread,
Jul 22, 2004, 12:56:09 PM7/22/04
to
Kevin wrote:
> I have a program that needs to run in the backround on a server 24/7 for
> sales order processing. I need to set the program's user date each night.
> I have a vbscript that runs in the scheduled tasks to do this. The script
> checks to see if the program is active and if it is it performs a F9
> sendkey. This works only if the target program is not minimized. If the
> window is in normal or max mode I guess, it works just fine. How can I
> modify this vbscript to force the program to display it's window full screen
> before I send the F9 key?
Hi

WshShell.AppActivate does not support this (at least not on
NT4/Win2k/WinXP/Win2k3), but AutoItX does, so this should work:

Set oAutoIt = CreateObject("AutoItX.Control")
oAutoIt.SetTitleMatchMode 2

oAutoIt.WinActivate "Program Window Name", ""
oAutoIt.WinWaitActive "Program Window Name", ""
oAutoIt.Send "{F9}"
WScript.Sleep 1000
oAutoIt.Send "{ENTER}"


AutoIt/AutoItX is free and can be found here:
http://www.hiddensoft.com/AutoIt/

AutoItX is an ActiveX control version of AutoIt and can be used
from a vbscript.


Note: It's defaults is to match the start of a window title that you
specify, use "SetTitleMatchMode 2" to specify ANY substring of the
window title you want to match.


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Kevin

unread,
Jul 22, 2004, 1:14:36 PM7/22/04
to
The code actually acted the same way. I did have to change the syntax a
bit.

from


returnValue = WshShell.AppActivate( "Program Window Name"), MAXIMIZE_WINDOW

to
returnValue = WshShell.AppActivate( "Program Window Name", MAXIMIZE_WINDOW)

Thanks for helping, this seems like it ought to be so simple......

Kevin

"thunder2232" <thund...@discussions.microsoft.com> wrote in message
news:4FC89889-9019-4041...@microsoft.com...

thunder2232

unread,
Jul 22, 2004, 1:53:02 PM7/22/04
to
Thanks for the tip about AutoIT... I wasn't sure if AppActivate supported the MAXIMIZE_WINDOW, but it was worth a try...

Kevin

unread,
Jul 22, 2004, 4:09:33 PM7/22/04
to
Thanks very much! It looks like this will do the trick. What a great
little program.

Kevin

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:%2327Ba0A...@TK2MSFTNGP11.phx.gbl...

0 new messages