2016-11-25 46 views
0

我需要在进程发生错误时用脚本截图。有没有办法将除了一个之外的所有窗口最小化?

是否有一种方法来最小化所有窗口,除了获得错误的进程的窗口?

我知道,以尽量减少一路:

$shell = new-object -com shell.application 
$shell.MinimizeAll() 

但是,有没有办法,除了一个窗口,以尽量减少一切吗?

谢谢!

+0

你可以使用[的ShowWindow()](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85% 29.aspx)到[恢复相关窗口](https://gist.github.com/IISResetMe/819dbc4c71b3bc9768db)后最小化所有 –

回答

1

使用API​​的Windows

$Win32ShowWindowAsync = Add-Type –memberDefinition @” 
[DllImport("user32.dll")] 
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); 
“@ -name “Win32ShowWindowAsync” -namespace Win32Functions –passThru 

$titletowindow="TODO.csv - Bloc-notes" 

get-process | 
     where mainwindowhandle -ne 0 | 
      %{if ($_.MainWindowTitle -eq $titletowindow) { $Win32ShowWindowAsync::ShowWindowAsync($_.MainWindowHandle, 3) | Out-Null} else { $Win32ShowWindowAsync::ShowWindowAsync($_.MainWindowHandle, 6) | Out-Null} } 
+0

对不起,方式太迟反馈,完美工作,thx! – SimonS

相关问题