Reputation: 213
I've disabled the standard WIN key shortcuts for a reason, so I can't for example invoke WIN+M or WIN+D which would have done something similar to what I want.
I want to minimize all open windows on all monitors.
I've tried this myself in several ways, of which the most obvious seems to be:
#M::
WinMinimizeAll
return
This, however, only minimizes the windows that are on the main monitor, while the windows on other monitors are unaffected.
I've also tried looping through all windows gotten from WinGet and the like, but it seems to find processes that aren't really GUI windows and minimizing those too, resulting in weird grey box artifacts down by the taskbar that aren't clickable.
Is this doable and how? If I need another software to make it happen that could also be a good answer.
Upvotes: 0
Views: 863
Reputation: 10568
If you don't have DetectHiddenWindows On
in your script, WinGet is a good alternative:
SetWinDelay -1
$F1::MinimizeAll()
$F2::RestoreAll()
MinimizeAll(){
DetectHiddenWindows Off
WinGet, id, list
Loop, %id%
{
this_ID := id%A_Index%
If NOT IsWindow(WinExist("ahk_id" . this_ID))
continue
WinGet, WinState, MinMax, ahk_id %this_ID%
If (WinState = -1)
continue
WinGetTitle, title, ahk_id %this_ID%
If (title = "")
continue
WinMinimize, ahk_id %this_ID%
}
}
RestoreAll(){
DetectHiddenWindows Off
WinGet, id, list
Loop, %id%
{
this_ID := id%A_Index%
If NOT IsWindow(WinExist("ahk_id" . this_ID))
continue
WinGet, WinState, MinMax, ahk_id %this_ID%
If (WinState != -1)
continue
WinGetTitle, title, ahk_id %this_ID%
If (title = "")
continue
WinRestore, ahk_id %this_ID%
}
}
; Check whether the target window is activation target
IsWindow(hWnd){
WinGet, dwStyle, Style, ahk_id %hWnd%
if ((dwStyle&0x08000000) || !(dwStyle&0x10000000)) {
return false
}
WinGet, dwExStyle, ExStyle, ahk_id %hWnd%
if (dwExStyle & 0x00000080) {
return false
}
WinGetClass, szClass, ahk_id %hWnd%
if (szClass = "TApplication") {
return false
}
return true
}
Upvotes: 1