Adds a window specification to a window group, creating the group if necessary.
GroupAdd GroupName , WinTitle, WinText, ExcludeTitle, ExcludeText
The name of the group to which to add this window specification. If the group doesn't exist, it will be created. Group names are not case sensitive.
Type: String, Integer or Object
A window title or other criteria identifying the target window. See WinTitle.
If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON at the time that GroupActivate, GroupDeactivate, and GroupClose are used.
Windows whose titles include this value will not be considered.
Windows whose text include this value will not be considered.
Each use of this function adds a new rule to a group. In other words, a group consists of a set of criteria rather than a fixed list of windows. Later, when a group is used by a function such as GroupActivate, each window on the desktop is checked against each of these criteria. If a window matches one of the criteria in the group, it is considered a match.
Although SetTitleMatchMode and DetectHiddenWindows do not directly affect the behavior of this function, they do affect the other group functions such as GroupActivate and GroupClose. They also affect the use of ahk_group in any other function's WinTitle.
A window group is typically used to bind together a collection of related windows, which is useful for tasks that involve many related windows, or an application that owns many subwindows. For example, if you frequently work with many instances of a graphics program or text editor, you can use GroupActivate on a hotkey to visit each instance of that program, one at a time, without having to use alt-tab or task bar buttons to locate them.
Since the entries in each group need to be added only once, this function is typically used during script startup. Attempts to add duplicate entries to a group are ignored.
To include all windows in a group (except the special Program Manager window), use this example:
All windowing functions can operate upon a window group by specifying
ahk_group MyGroupName for the WinTitle parameter. The functions WinMinimize, WinMaximize, WinRestore, WinHide, WinShow, WinClose, and WinKill will act upon all the group's windows. To instead act upon only the topmost window, follow this example:
WinHide WinExist("ahk_group MyGroup")
By contrast, the other window functions such as WinActivate and WinExist will operate only upon the topmost window of the group.
GroupActivate, GroupDeactivate, GroupClose
; In the autoexecute section at the top of the script: GroupAdd "MSIE", "ahk_class IEFrame" ; Add only Internet Explorer windows to this group. return ; End of autoexecute section. ; Assign a hotkey to activate this group, which traverses ; through all open MSIE windows, one at a time (i.e. each ; press of the hotkey). Numpad1::GroupActivate "MSIE", "r"
#2: Here's a more complex group for MS Outlook 2002.
; In the autoexecute section at the top of the script: SetTitleMatchMode 2 GroupAdd "mail", "Message - Microsoft Word" ; This is for mails currently being composed GroupAdd "mail", "- Message (" ; This is for already opened items ; Need extra text to avoid activation of a phantom window: GroupAdd "mail", "Advanced Find", "Sear&ch for the word(s)" GroupAdd "mail", , "Recurrence:" GroupAdd "mail", "Reminder" GroupAdd "mail", "- Microsoft Outlook" return ; End of autoexecute section. Numpad5::GroupActivate "mail" ; Assign a hotkey to visit each Outlook window, one at a time.