I'm looking for a way to use a keyboard shortcut to minimize all the windows on the monitor that currently has my mouse on it. I found this page: http://vbcity.com/forums/t/163339.aspx but that appears to be hardcoded to minimize windows on a specific monitor, rather than the active monitor. Plus, I have no idea how to compile that code (not a VB coder). Anybody know a way that I can make this happen? I'm on Windows 7 ultimate, 3 monitors.
4 Answers
Under Windows 7, here is the list of the keyboard shortcuts that manage multiple windows :
Win+d
Minimize all windows on all Monitors. Press again to restore previous state
Win+m
Minimize all windows on all Monitors.
Win+Shift+m
Restore previously minimized windows on current Monitor
Win+Home
Set all windows to Minimized on current Monitor except active
Win+Space
Preview Desktop / make windows transparent (May not work with all Settings)
Source : 127 useful Keyboard Shortcuts for Windows 7.
The OP notes that Actual Multiple Monitors has an option for "Minimize All command affects only the monitor with mouse".

The other answer, although superior, is not as fun as mine. Take one active window and shake it. All other windows will be minimized. Then minimize that window
I found another way to resolve this problem. I write autohotkey script to make all program minimize except some program. I often move Xshell and git command to another monitor, so I make them maximize again. The script like following, hope can help you.
#d::get()
get(){
WinMinimizeAll
WinGet, active_id, ID, ahk_exe Xshell.exe
WinMaximize, ahk_id %active_id%
WinGet, active_id, ID, ahk_exe mintty.exe
WinMaximize, ahk_id %active_id%
}
You can replace "Xshell.exe" and "mintyy.exe" with another program and move them to another monitor then press Win+d to make all program minimize exclude you specified. How to run autohotkey you can click here.
- 111
- 1
- 1
- 3
Either download this app or you can run this Powershell code based on it. This script just minimizes the windows on the monitor where the mouse cursor is when running the script, but it doesn't restore them like the app does.
# Powershell script: ShowDesktopCurrDisplay.ps1
#
# P/Invoke declaration for Windows API
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
using System.Text;
public class Win32Functions {
public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
[StructLayout(LayoutKind.Sequential)]
public struct POINT {
public int X;
public int Y;
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT {
public int Left;
public int Top;
public int Right;
public int Bottom;
}
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPLACEMENT {
public int Length;
public int flags;
public int showCmd;
public POINT ptMinPosition;
public POINT ptMaxPosition;
public RECT rcNormalPosition;
}
[DllImport("user32.dll")]
public static extern IntPtr MonitorFromPoint(POINT pt, uint dwFlags);
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out POINT lpPoint);
[DllImport("user32.dll")]
public static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
public static extern IntPtr MonitorFromWindow(IntPtr hWnd, uint dwFlags);
[DllImport("dwmapi.dll")]
public static extern int DwmGetWindowAttribute(IntPtr hWnd, uint dwAttribute, out bool pvAttribute, uint cbAttribute);
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
public static extern long GetWindowLongPtr32(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
public static extern long GetWindowLongPtr64(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}
"@
Find the display handle where the mouse cursor is
or retrieve the primary display in case it is not available
$mouse_point = New-Object Win32Functions+POINT
if ([Win32Functions]::GetCursorPos([ref]$mouse_point)) {
$handleCurrentMonitor = [Win32Functions]::MonitorFromPoint($mouse_point, 1)
} else {
Write-Error "Unable to find mouse pointer!"
return
}
Build the window handles list
$WindowHandles = [System.Collections.Generic.List[IntPtr]]::new()
Define the callback function
$callback = {
param([IntPtr]$handle, [IntPtr]$param)
Add the handle to the list
$WindowHandles.Add($handle)
Continue (return $false to stop the enumeration)
return $true
}
Enumerate the windows
if([Win32Functions]::EnumWindows($callback, [IntPtr]::Zero)){
foreach ($handle in $WindowHandles) {
# Check if the window is cloaked (DWMWA_CLOAKED)
$windowCloaked = $false
[Win32Functions]::DwmGetWindowAttribute($handle, 14, [ref]$windowCloaked, [System.Runtime.InteropServices.Marshal]::SizeOf($windowCloaked)) | Out-Null
if ($windowCloaked) {
# Cloaked, hidden window
continue
}
# Get the window styles
if ([IntPtr]::Size -eq 8) {
$winStyle = [Win32Functions]::GetWindowLongPtr64($handle, -16)
$winExStyle = [Win32Functions]::GetWindowLongPtr64($handle, -20)
} else {
$winStyle = [Win32Functions]::GetWindowLongPtr32($handle, -16)
$winExStyle = [Win32Functions]::GetWindowLongPtr32($handle, -20)
}
if ($winStyle -band 0x8000000) {
# disabled = skip
continue
}
if (!($winStyle -band 0x10000000)) {
# (not) visible = skip
continue
}
if ($winExStyle -band 0x8000000) {
# Ex NoActivate = hidden = skip
continue
}
if ($winExStyle -band 0x80) {
# Ex ToolWindow = skip
continue
}
#if ($winExStyle -band 0x40000) {
# Ex AppWindow = process this window only
#}
# Debug: get the window text (currently not used)
#$windowText = New-Object System.Text.StringBuilder(256)
#$windowTextSize = [Win32Functions]::GetWindowText($handle, $windowText, 256)
# Check that the display is the same
$windowMonitor = [Win32Functions]::MonitorFromWindow($handle, 1)
if ($windowMonitor -eq $handleCurrentMonitor) {
# Same display
#Write-Host "Window Name: $($windowText.ToString())"
# Minimize this window
if ($winStyle -band 0x10000000) {
[Win32Functions]::ShowWindow($handle, 2) | Out-Null
}
}
}
}
To run this, just create a shortcut with Run minimized option and this command:
powershell -WindowStyle Hidden -ExecutionPolicy Bypass -File ShowDesktopCurrDisplay.ps1
and then add it to your taskbar icons for example (or set an hotkey).
- 286