cmd / powershell:最小化桌面上除当前命令提示符(控制台)以外的所有窗口或某些特定窗口除外(cmd / powershell: minimize all windows on your

编程入门 行业动态 更新时间:2024-10-09 18:21:12
cmd / powershell:最小化桌面上除当前命令提示符(控制台)以外的所有窗口或某些特定窗口除外(cmd / powershell: minimize all windows on your desktop except for current command prompt (console) or except for some particular window)

好吧,我知道如何通过使用powershell方法最小化桌面上所有打开的窗口--MinimizeAll():

powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }"

问题是:这种方法可以最大限度地减少包括当前cmd-console在内的一切,在我的情况下,用户始终可以看到它。

现在,要解决此问题,我使用外部nircmd.exe工具,我的.bat文件的这部分如下所示:

:: change current command prompt window title title my-cmd-console :: minimize all open windows on the desktop with powershell command powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }" :: bring console back to the front with nircmd.exe command 'win activate [filter window by title]' nircmd.exe win activate title "my-cmd-console"

我不喜欢这段代码的是屏幕上有很多“闪烁”:开始时,控制台出现在桌面上,然后它与所有其他窗口一起被最小化,然后它再次被带回桌面前面。

所以,问题是:如何使控制台出现在桌面前面并“锁定”,以便在达到命令行EXIT之前它永远不会消失。

PS不确定,但也许有一个替代解决方案'最小化所有除了特定窗口'问题,而无需使用外部nircmd.exe工具。 有任何想法吗?

well, I know how to minimize all open windows on the desktop from a batch file by using powershell method - MinimizeAll():

powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }"

the problem is: this method minimizes everything including current cmd-console which should be in my case always visible to the user.

now, to workaround this problem I use external nircmd.exe tool and this part of my .bat-file looks like this:

:: change current command prompt window title title my-cmd-console :: minimize all open windows on the desktop with powershell command powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }" :: bring console back to the front with nircmd.exe command 'win activate [filter window by title]' nircmd.exe win activate title "my-cmd-console"

what I don't like about this code is that there is much 'flashing' on the screen: at start, the console appears on the desktop, then it gets minimized with all other windows and then it's brought back on the desktop front again.

so, the question is: how to make console appear on the desktop front and 'lock it', so that it never gets out of sight until the command line EXIT is reached.

P.S. not sure, but maybe there is an alternative solution to 'minimize all except for particular window' problem without need to use external nircmd.exe tool. any ideas?

最满意答案

最小化除活动窗口之外的所有窗口(切换命令):

nircmd sendkeypress rwin+home

minimize all but the active window (toggling command):

nircmd sendkeypress rwin+home

更多推荐

本文发布于:2023-08-03 19:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1396173.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗口   最小化   控制台   命令提示符   桌面上

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!