Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Is there any way to destroy (delete) a window group


  • Please log in to reply
4 replies to this topic
Gogo
  • Guests
  • Last active:
  • Joined: --
Actually, I need to modify a particular rule from an ahk_group, but destroying and rebuilding it is acceptable, too. Reload, however, is very problematic alternative.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
you need to modify the rule after the script is running? and just adding more rules isn't what you need? This could be tricky. Perhaps you need a variable number of groups, and each time you rebuild the group, you use a new name (Autoincrement), and update "currentGroup" with the name of the group in question.

Eventually you will create many groups, though, which may not be what you want. I don't see anything at all about deleting Groups.

  • Guests
  • Last active:
  • Joined: --
There has been a workaround but i never tried it (no use for it ....)

<!-- m -->http://www.autohotke...278.html#139278<!-- m -->

Gogo
  • Guests
  • Last active:
  • Joined: --
Thanks for your replies.
They gave me good ideas and I wrote a simple function GroupInit().
; --------- Example ---------------------
GroupInit(MyGroup)               ; You have to initialize the group before first GroupAdd
GroupAdd %MyGroup%, Notepad      ; You have to use [color=black]%MyGroup%[/color] in GroupAdd
WinWait ahk_group %MyGroup%      ; and [color=black]ahk_group %MyGroup%[/color] in Win-commands
WinClose % "ahk_group" MyGroup   ; or [color=black]"ahk_group" MyGroup[/color] in expression mode
GroupInit(MyGroup)               ; "Deletes" the group (creates new empty group)
; ---------------------------------------

GroupInit(ByRef GroupName){    ; Stores new name
  static g:= 1                 ; of an empty window group
  GroupName:= "Group" g++      ; into the passed variable
}


Gogo
  • Guests
  • Last active:
  • Joined: --
I found slightly different, but much better solution. It's a replacement of the GroupAdd command.
; --------- Example ---------------------
GroupAdd(MyGroup, "Untitled")       ; You have to use expression syntax in functions
WinWaitActive ahk_group %MyGroup%   ; and ahk_group %MyGroup% in Win-commands
WinMinimize % "ahk_group" MyGroup   ; or "ahk_group" MyGroup in expression mode
MyGroup =                           ; "Deletes" the group
; ---------------------------------------

GroupAdd(ByRef GroupName,p1="",p2="",p3="",p4="",p5=""){
  static g:= 1
  If (GroupName = "")
     GroupName:= "AutoName" g++
  GroupAdd %GroupName%, %p1%, %p2%, %p3%, %p4%, %p5%
}

usage: GroupAdd(GroupNameVar [, WinTitle, WinText, Label, ExcludeTitle, ExcludeText]) see AHK Help
example: GroupAdd(MyGroup, "Notepad")

The GroupAdd() function has the same parameters and remarks like GroupAdd command, but now MyGroup is a variable which contains the window group name. If MyGroup is empty, GroupAdd() will generate an unique AutoName# of a new empty window group, will store it in the variable and will add the requested criterion to the new group.
If MyGroup is not empty GroupAdd() will act exactly like GroupAdd command.

Remarks:
- GroupAdd() is a function, so its parameters must obey expression syntax (i.e. variables must be unquoted, strings like "Notepad" or "ahk_id" must be in quotes).
- MyGroup is a variable and in Win-commands like WinWait ahk_group %MyGroup% it must be in %%, unless it is in an expression mode (WinClose % "ahk_group" MyGroup).
- To delete the group just delete the variable (MyGroup = ). Next GroupAdd() will create new empty group.
- If you delete a group included in another group this will not affect the second group.

Search tags: GroupDelete GroupClear WinGroup WinGroupDelete WinGroupClear WinGroupInit