Close all windows of same type as current foreground window
I don't know if this is possible.
I would like to have a hotkey for closing all windows that are of the same type as te current foreground window.
For example: if the current active window is a cmd i want to close with one hotkey alls cmd windows running.
Would be a great addition to my autohotkeys.
thx & greets.
You can use title (the end of a firefox window ends in "- Mozilla Firefox") or class (ahk_class something). Get the class of the active window with WinGetClass, or the title ending with WinGetTitle, InStr(), and SubStr(). Then use "WinGet, List" and Loop through each window to see if it meets the same criteria as the formerly active one. If so, WinClose it.
If you get stuck post your code in
[code][/code]tags and we'll help out. Good luck :wink:
This script creates a group with a name similar to the WinClass of the active window and adds this class into it.
This command operates only upon the topmost matching window except when WinTitle is ahk_group GroupName, in which case all windows in the group are affected.
StringReplace command replaces eventual spaces in the class as they are illegal in the group name.
F1:: WinGetClass class, A StringReplace grp, class, %A_Space%, _ , All GroupAdd %grp%, ahk_class %class% WinClose ahk_group %grp% return