Hi,
My earlier script is a feeble attempt to target only windows that are visible. It is probably faulty. There are other posts on the forum that describe how to use window styles to distinguish visible from non-visible windows. I have never found them to be completely reliable for all windows. You can craft your own rules to indicate what windows to include or exclude. I typically have some windows that I exclude by window title; specifying them is generally straightforward. There could be other approaches, too, including possibly checking the coordinates of the window. I have not tested that.
Displaying a list of all window titles may be informative as you refine your script. You will find Program Manager, windows with null titles, etc.
Code: Select all
#Requires AutoHotkey v1.1.35
WinGet win, List
str := ""
Loop % win {
WinGetTitle title, % "ahk_id" win%A_Index%
str .= title "`n"
}
MsgBox 64, Window titles, % A_Clipboard := str
Return
I wrote a script that I have called "CloseAll". It works reasonably well. It checks for this window style value before proceeding:
winStyle & 0x10000000. That is the style from WinGet, Style. It then also handles my exclusions, and excludes windows with null titles. My exclusions include Citrix Workspace, MainWindow, Program Manager, Start, Windows Task Manager, ApplicationFrameHost, ctfmon, but this list can be customized as needed.
The following post shows an approach to using both the style and the extended style. I have used this with some success.
viewtopic.php?p=505727#p505727