How can I maximize, restore, or minimize a window with a vbscript?

后端 未结 4 2012
粉色の甜心
粉色の甜心 2020-12-05 08:35

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

4条回答
  •  忘掉有多难
    2020-12-05 09:18

    Topic is old. But I managed to find language independent solution. SendKeys can basically send any keys to application, including arrow keys and enter key. So we can emulate those actions without particular letters (x,r,n). Here is working example:

    Dim oShell : Set oShell = CreateObject("WScript.Shell")
    oShell.SendKeys("% {DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")   'Maximize
    '...
    oShell.SendKeys("% {ENTER}")   'Restore
    '...
    oShell.SendKeys("% {DOWN}{DOWN}{DOWN}{ENTER}")   'Minimize
    

提交回复
热议问题