Hi.
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.
Close all windows of same type as current foreground window
Started by
some matthias
, Dec 01 2011 10:47 AM
3 replies to this topic
#1
-
Posted 01 December 2011 - 10:47 AM
First you need to choose a way to identify windows of "the same type"
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
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:
#2
-
Posted 01 December 2011 - 12:37 PM
Windows that are of the same type have the same WinClass. To close all windows of the same type they should be added to a group.
StringReplace command replaces eventual spaces in the class as they are illegal in the group name.
This script creates a group with a name similar to the WinClass of the active window and adds this class into it.AHK Help/Index/WinClose:
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
#3
-
Posted 01 December 2011 - 12:51 PM