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

Using VBScript to minimize, restore/maximize, close window

25,461 views
Skip to first unread message

robert_l._stokes

unread,
Apr 24, 2001, 9:58:11 PM4/24/01
to

I would like use VBScript to do the equivilant of mouseclicking to
minimize, maximize/restore or close a window in which I have
made sendkey entries. I assume one procedure works for all windows
with the minimize, restore/maximize, close button.

set Shell = WScript.CreateObject("WScript.Shell")
shell.run "notepad"
wscript.sleep(5000)
shell.sendkeys("test")
'>>> procedure to minimize, restore/maximize, close window

Michael Harris

unread,
Apr 25, 2001, 12:48:10 AM4/25/01
to
Note that the WScript.Sleep calls are more for effect in demonstration than anything else.
Depending on the keystrokes you send and the responsiveness of the application, you may have to use
a few strategically placed WScript.Sleep calls to let the application react...

=======================================

set shell = createobject("wscript.shell")
shell.run "about:blank"

wscript.sleep 2000
success = shell.appactivate("about:blank")
if success then shell.sendkeys "% n" '...minimize

wscript.sleep 2000
success = shell.appactivate("about:blank")
if success then shell.sendkeys "% x" '...maximize

wscript.sleep 2000
success = shell.appactivate("about:blank")
if success then shell.sendkeys "% r" '...restore

wscript.sleep 2000
success = shell.appactivate("about:blank")
if success then shell.sendkeys "%{F4}" '...maximize

--
Michael Harris
Microsoft.MVP.Scripting
--
mik...@mvps.org
Please do not email questions - post them to the newsgroup instead.
--

<Robert L. Stokes> wrote in message news:3ae62eec.6989032@news...

Glen

unread,
Apr 25, 2001, 6:08:43 AM4/25/01
to
In article <3ae62eec.6989032@news>, Robert L. Stokes says...

to maximize -

s.sendkeys "(% )X"

to minimize -

s.sendkeys "(% )N"

try pressing ALT-SPACE in any window for your other options

f


0 new messages