Hung windows and taskbar buttons rearrangement
Did the above ever happen to you?
I sometimes encounter the issue, which is not critical, but may be very annoying at times.
I’ve also received a couple of bug reports about it, so I decided to take a closer look.
First things first: reproduction
Before doing further analysis, I needed a reliable way to reproduce the rearrangement of taskbar buttons.
For this reason I wrote a hang-test program, whose purpose is to hang 🙂
But just a hang wasn’t enough. A simple program that doesn’t respond for several seconds may lead to rearrangement on the taskbar, but it usually doesn’t.
After some experiments, I added a message box creation and some load on the CPU, which made it reproduce the issue most of the time on my PC.
You can grab the program here:
hang_test.zip (9.09 kB)
Investigating the issue
So, why does the rearrangement happen? Why isn’t it consistent, i.e. happens only at times?
The first thing you should know: when a window stops responding, Windows creates a special window of the class “Ghost”, which replaces the hung window.
You can read more about it here.
Now, how does explorer handle the replacement?
Explorer receives the “SysFrostedWindow” message (registered with RegisterWindowMessage) with two parameters: the replaced window and the replacing window.
Upon receiving the message, it just replaces the window of the taskbar button.
But the problem is that it doesn’t always receive the message on time!
So this is what happens:
- The window hangs.
- The system creates a “Ghost” window.
- Explorer receives the “SysFrostedWindow” message, and replaces the windows.
- The window becomes responsive again.
- The system removes the “Ghost” window.
- Before receiving the “SysFrostedWindow” message, explorer validates the taskbar button, which is no more valid as the “Ghost” window doesn’t exist anymore. The taskbar button gets removed.
- Explorer receives the “SysFrostedWindow” message, and creates a new taskbar button (as there’s nothing to replace).
Fixing
When a hung window is replaced with a “Ghost” window, I write down the both windows. Then, when the taskbar button is accessed, I validate whether the “Ghost” window still exists, and if not, I restore the original window right away, without waiting for the “SysFrostedWindow” message.
The fix is available in 7+ Taskbar Tweaker v4.2.3, and is enabled by default.
Tags: 7+ taskbar tweaker
Good idea. Thanks much.
Awesome! Love the detailed explanation too.
Thanks.
Thanks for the update 🙂
I have come across a bug ONLY when I enable the “Don’t show jump list when dragging a taskbar item towards the desktop” option.
Here is a video: http://youtu.be/1HImtFnSIYw
Hope it helps.
Fixed in v4.2.4.
Thank you very much! 🙂
You have no idea how util this is!
Thanks for this great program and for the explanation too, it’s great to learn a little more about what’s happening behind
A million thank you’s!
http://www.hallmark.com/products/thank-you/ecards/a-million-thanks-npg6320_DK/
You’re welcome 🙂
I’ve never seen free software updated so often, it’s awesome. Thanks
Great fix, this is one of those things I thought I would have to live with forever.
BTW, have you though about giving us the possibility of relocating taskbar buttons via command line? Something like:
7+ Taskbar Tweaker.exe -reloc WinTitle newpos
Thank you for your program!
Nope, haven’t thought about it.
Why would you need that?
For example, you can programmatically restart programs and have them positioned automatically.
Or you can make a .bat to quickly reposition all the programs you usually work with in the order you prefer:
“7+ Taskbar Tweaker.exe” -reloc “outlook” 0
“7+ Taskbar Tweaker.exe” -reloc “*mozilla firefox” 1
etc.
This could be executed via a timer or an Autohotkey hotkey.
If we could also be able to query the current location of a program (not so sure how we could do this) we could also position Word to the right of Excel, for example.
Along with numeric (absolute) positions you could also implement relative ones (last, last-1, etc. or even excel+1).
Thank you for taking this into consideration.
Cheers,
mprost
It would also be great for this command line functionality to be able to control Windows 8’s secondary taskbar (the one that appears in the secondary monitor), as this taskbar tends to be a mess when you are constantly moving windows from one monitor to another.
Hi! I actually had this problem when Firefox freezes on a page for some seconds: if I have it in the first position, it always goes to the last position. Very annoying!
I think 7+ Taskbar fixed it. Many thanks!
Thanks! I had been noticing this with Skype (I think). It was being shoved to the end of the Taskbar after I’d restart the computer, and even when I tried to put it back in its place manually, it would jump back to the end!
Same thing happens to me v4.2.6 win7 64
I unlocked the taskbar and moved the icon where i wanted it and it stayed, relocked the taskbar, probably won’t know if it will stick until a couple of reboots
Greetings,
After having scanned registry I have lost an access to the program features.
What registry entries shall I put to the ‘exception’ in order to avoid the problem?
Thank you in advance.
Hi,
The tweaker uses the following registry branch for it’s settings:
HKEY_CURRENT_USER\Software\7 Taskbar Tweaker
Thank you very much. I will give a try.
The true solution to this problem is to just stop using windows.