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.

Is there any way to destroy (delete) a window group
Started by
Gogo
, Sep 23 2011 10:57 AM
4 replies to this topic
#1
-
Posted 23 September 2011 - 10:57 AM

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.
Eventually you will create many groups, though, which may not be what you want. I don't see anything at all about deleting Groups.
#2
-
Posted 23 September 2011 - 01:18 PM

There has been a workaround but i never tried it (no use for it ....)
<!-- m -->http://www.autohotke...278.html#139278<!-- m -->
<!-- m -->http://www.autohotke...278.html#139278<!-- m -->
#3
-
Posted 23 September 2011 - 02:12 PM

Thanks for your replies.
They gave me good ideas and I wrote a simple function GroupInit().
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 }
#4
-
Posted 24 September 2011 - 01:03 PM

I found slightly different, but much better solution. It's a replacement of the GroupAdd command.
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
; --------- 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
#5
-
Posted 25 September 2011 - 03:36 PM
