# GroupClose

Closes the active window if it was just activated by GroupActivate or GroupDeactivate. It then activates the next window in the series. It can also close all windows in a group.

GroupClose, GroupName [, A|R]

#### Parameters

GroupName | The name of the group as originally defined by GroupAdd.
A|R | If it's the letter A, all members of the group will be closed. This is the same effect as WinClose ahk_group GroupName. Otherwise: If the command closes the active window, it will then activate the next window in the series. This parameter determines whether the oldest or the newest window is activated. If omitted, the oldest window is always activated. If it's the letter R, the newest window (the one most recently active) is activated, but only if no members of the group are active when the command is given. "R" is useful in cases where you temporarily switch to working on an unrelated task. When you return to the group via GroupActivate, GroupDeactivate, or GroupClose, the window you were most recently working with is activated rather than the oldest window.

#### Remarks

When the A|R parameter is not "A", the behavior of this command is determined by whether the previous action on GroupName was GroupActivate or GroupDeactivate. If it was GroupDeactivate, this command will close the active window only if it is not a member of the group (otherwise it will do nothing). If it was GroupActivate or nothing, this command will close the active window only if it is a member of the group (otherwise it will do nothing). This behavior allows GroupClose to be assigned to a hotkey as a companion to GroupName's GroupActivate or GroupDeactivate hotkey.

See GroupAdd for more details about window groups.

#### Related

GroupAdd, GroupActivate, GroupDeactivate

#### Example

    GroupClose, MyGroup, R