If you often have multiple instances of applications (e.g., several Microsoft Word documents, several Microsoft Excel spreadsheets) open on your desktop, one of the handiest Windows features is taskbar-button grouping, which was introduced in Windows XP. As you probably know, for each instance of an application, Windows places a button in the taskbar. The taskbar can get crowded if you have a lot of buttons. Instead of having virtually unreadable taskbar buttons in multiple rows at the bottom of the screen, you can group taskbar buttons.

You can control whether taskbar buttons are grouped by right-clicking the Start button, choosing Properties from the context menu, and selecting the Taskbar tab. As Figure 1 shows, you select the Group similar taskbar buttons check box to group buttons or clear the check box to ungroup them.

When the check box is selected (which is the default), taskbar buttons from the same application are grouped, but you have no control over when grouping starts or ends. This behavior is disconcerting because as you open and close instances of applications, buttons spontaneously group and ungroup, causing the buttons to shift around. What’s worse is that when buttons are ungrouped, you can’t use the Close Group option.

Although you can use the TweakUI tool to tweak grouping behavior, this tool isn’t available for Windows Vista. (TweakUI is part of the Microsoft PowerToys for Windows XP.) TweakUI’s cousin— Tweakomatic—will run on the 32-bit edition but not the 64-bit edition of Vista.

So, if you have the 64-bit edition of Vista or you just want to tweak grouping behavior on your own, you can do so by creating a registry entry named TaskbarGroupSize under the HKEY_CURRENT_USER\Software Microsoft\Windows\CurrentVersion Explorer\Advanced key. The TaskbarGroup- Size entry has an effect only when the Group similar taskbar buttons feature is enabled.

When you set Taskbar- GroupSize’s DWORD value to 0, Windows will group the buttons by age, which is the default grouping behavior. For example, suppose you launch Word, Excel, then Notepad, after which you open many files in each application. When the taskbar gets too crowded, Windows will group the buttons for the Word files first because Word was launched first, provided that it isn't a Word file that's prompting the grouping. If that's the case, the second application launched (Excel in this example) will group first.

When you set TaskbarGroupSize’s value to 1, Windows will group the buttons for the application with the most windows open first. When you set the value to any other number, Windows will automatically group the buttons for any application that has at least that many windows open. So, by setting the TaskbarGroupSize value to 2, you can force buttons to always group, which is the behavior I prefer.

To make the registry tweak, I wrote short script named TaskbarGroupSize.vbs. You can download this script by clicking the Download the Code Here button at the top of the page.

When you run the script by simply double-clicking it, it returns the current value for TaskbarGroupSize. If that entry hasn’t been created, it returns the value undefined, as Figure 2 shows. When you launch the script from the command line and provide a numeric argument, it sets TaskbarGroupSize to that value for you.