cmd / powershell:最小化桌面上除当前命令提示符(控制台)或某些特定窗口以外的所有窗口 [英] cmd / powershell: minimize all windows on your desktop except for current command prompt (console) or except for some particular window

查看:385
本文介绍了cmd / powershell:最小化桌面上除当前命令提示符(控制台)或某些特定窗口以外的所有窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我知道如何使用Powershell方法-MinimizeAll()从批处理文件中最小化桌面上所有打开的窗口:

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() }"

问题是:此方法将包括当前cmd-console在内的所有内容最小化,在我看来,该cmd-console对用户始终是可见的。

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

现在,要解决此问题,我使用了外部 nircmd.exe 工具以及我的.bat文件的这一部分-file看起来像这样:

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.

PS
不确定,但是也许有另一种解决方案可以最小化除特定窗口外的所有内容问题,而无需使用外部 nircmd.exe 工具。有任何想法吗?

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?

推荐答案

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

minimize all but the active window (toggling command):

nircmd sendkeypress rwin+home 

这篇关于cmd / powershell:最小化桌面上除当前命令提示符(控制台)或某些特定窗口以外的所有窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆