问题描述
我需要能够制作单独的 .vbs 文件,这些文件(当用键盘快捷键触发时)将使活动窗口最大化、最小化或恢复.
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.
推荐答案
VBScript 和 Windows Script Host 不提供最大化/最小化/恢复窗口的内在函数.在没有任何第三方工具的情况下,您唯一的选择是使用 SendKeys
模拟键盘窗口系统菜单中相应命令的快捷键.
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.
为了最大化活动窗口,你可以模拟+、快捷键:
Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "% x"
要最小化活动窗口,请使用 +、:
Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "% n"
要恢复活动窗口,请使用 +、:
Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "% r"
(请注意,此代码不适用于非英语 Windows 版本,其中最大化/最小化/恢复命令的名称已本地化,因此具有其他快捷方式.)
(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.)
这篇关于如何使用 vb 脚本最大化、恢复或最小化窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!