如何将CMD.EXE窗口置于顶部

时间:2021-09-17 06:29:50

How to bring CMD.EXE window to top? (I would prefer a command or script without a need to compile anything).

如何将CMD.EXE窗口置于顶部? (我更喜欢一个命令或脚本而不需要编译任何东西)。

3 个解决方案

#1


The Wscript.Shell object accessible from Windows Script Host (either VBS or JS) has a method called "AppActivate" which, when passed a window title, will attempt to "activate" (which may bring it to the foreground if it's not minimised).

可从Windows脚本宿主(VBS或JS)访问的Wscript.Shell对象有一个名为“AppActivate”的方法,当传递窗口标题时,将尝试“激活”(如果未最小化,可以将其带到前台) 。

The following code snippet in VBScript worked on my machine:

VBScript中的以下代码片段在我的机器上运行:

Set WShell = CreateObject("WScript.Shell")
WShell.AppActivate "Command Prompt"

(Edited: Initially I hadn't tried it. Then I did)

(编辑:最初我没试过。然后我做了)

#2


With compiling:

Easy, just use Win32 API to FindWindow according to its title or class and then send it a message or bring it to the front.

很容易,只需根据其标题或类使用Win32 API到FindWindow,然后发送消息或将其带到前面。

Without compiling:

I'd suggest you'd find a command line utility that can do the equivalent of FindWindow and SetForgroundWindow, so you could call it from a batch file or any other script.

我建议您找到一个命令行实用程序,它可以完成FindWindow和SetForgroundWindow的相同操作,因此您可以从批处理文件或任何其他脚本中调用它。

#3


You can make an AutoHotkey Script:

您可以制作AutoHotkey脚本:

^SPACE::  Winset, Alwaysontop, , Ahere
Return

Save it as a .ahk file. Run it after you've installed Autohotkey. Now click the window of your choice and hit CTRL+Space and the window should be always on top

将其另存为.ahk文件。安装Autohotkey后运行它。现在单击您选择的窗口并按CTRL + Space,窗口应始终位于顶部

#1


The Wscript.Shell object accessible from Windows Script Host (either VBS or JS) has a method called "AppActivate" which, when passed a window title, will attempt to "activate" (which may bring it to the foreground if it's not minimised).

可从Windows脚本宿主(VBS或JS)访问的Wscript.Shell对象有一个名为“AppActivate”的方法,当传递窗口标题时,将尝试“激活”(如果未最小化,可以将其带到前台) 。

The following code snippet in VBScript worked on my machine:

VBScript中的以下代码片段在我的机器上运行:

Set WShell = CreateObject("WScript.Shell")
WShell.AppActivate "Command Prompt"

(Edited: Initially I hadn't tried it. Then I did)

(编辑:最初我没试过。然后我做了)

#2


With compiling:

Easy, just use Win32 API to FindWindow according to its title or class and then send it a message or bring it to the front.

很容易,只需根据其标题或类使用Win32 API到FindWindow,然后发送消息或将其带到前面。

Without compiling:

I'd suggest you'd find a command line utility that can do the equivalent of FindWindow and SetForgroundWindow, so you could call it from a batch file or any other script.

我建议您找到一个命令行实用程序,它可以完成FindWindow和SetForgroundWindow的相同操作,因此您可以从批处理文件或任何其他脚本中调用它。

#3


You can make an AutoHotkey Script:

您可以制作AutoHotkey脚本:

^SPACE::  Winset, Alwaysontop, , Ahere
Return

Save it as a .ahk file. Run it after you've installed Autohotkey. Now click the window of your choice and hit CTRL+Space and the window should be always on top

将其另存为.ahk文件。安装Autohotkey后运行它。现在单击您选择的窗口并按CTRL + Space,窗口应始终位于顶部