tags:

views:

43

answers:

2

I need to be able to make separte .vbs files that will (when triggered with a keyboard short-cut) will make the active window maximized, minimized, or restored.

How can I do this without downloading and installing (not allowed here) a separate package.

+1  A: 

This might be helpful:
http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/6bb72ce257c762d/eb34dc688f832fc3?lnk=st&q=restore+running+application+vbscript&rnum=2

Sidharth Panwar
Replicating the relevant content here, mentioning the source, might be helpful. Long unreadable URLs into Microsoft pages have a track record of becoming dys-functional at some point, which would render this reply useless. ;-)
Tomalak
+1  A: 

VBScript and Windows Script Host don't provide intrinsic functions for maximizing/minimizing/restoring a window. Without any third-party tools, your only option is to use SendKeys to simulate keyboard the shortcuts of the corresponding commands in a window's system menu.

  • To maximixe the active window, you can simulate the Alt+      , x shortcut:

    Set oShell = CreateObject("WScript.Shell")
    oShell.SendKeys "% x"
    
  • To minimize the active window, use Alt+      , n:

    Set oShell = CreateObject("WScript.Shell")
    oShell.SendKeys "% n"
    
  • To restore the active window, use Alt+      , r:

    Set oShell = CreateObject("WScript.Shell")
    oShell.SendKeys "% x"
    

(Note that this code won't work in non-English Windows versions, where the names of the Maximize/Minimize/Restore commands are localized and therefore have other shortcuts.)

Helen
YEAH!!!!! FYI: I'm also using this method for text expansion as well!!!!!!
Keng