Alt+Tab Bug Worsened by IE 10, But Fix Found

Windows 7 has an annoying bug that causes alt+tab to malfunction for many people. This bug, previously discussed on this blog in Alt+Tab Depth Inversion Bug, causes the grid of programs to be partially or completely hidden, making it much harder to switch between programs. IE 10 adds to the ways of triggering this bug, making it harder to avoid than ever before.

On the bright side, working around other people’s bugs is one of my hobbies, and IE 10’s triggering of this bug pushed me to create a fix.

So now this bug can be banished forever, without upgrading to Windows 8, and without waiting for a fix from Microsoft. See the end for a link to the fix.

Update, the update again, November 2013: I reported that IE 10 was triggering this bug to Microsoft but they decided not to fix IE 10. I thought they had fixed IE 11, so I upgraded. I didn’t see the bug for a couple of days, but it is still there. Sigh…

(see Other Causes of Alt+Tab Problems for more details)

New causes

imageThe original bug was typically triggered by ipoint.exe or sidebar.exe. ipoint.exe is the Microsoft Intellipoint software, and sidebar.exe maintains the Windows gadgets, such as the clock. If either of these programs is running in Windows 7 then the bug may occur. The original ‘fix’ was to make sure that neither of these programs was running, and this worked quite well for me for four years.

And then, a few months ago, the bug came back – intermittently. It took a bit of observation and experimentation but eventually I found the cause. If you have IE 10 installed on Windows 7 and if you drag an Internet Explorer tab out of its window in order to create a new top-level IE window (tearing off a tab) then this bug may be triggered. I find this annoying because while it was no great sacrifice to never run ipoint.exe and sidebar.exe (I don’t know what ipoint.exe does and I have no interest in what sidebar.exe does), I do find tearing off tabs to be useful. So it was time to start investigating.

Research

There was a long-standing theory in the alt+tab conspiracy newsgroups that this bug was triggered by the presence of windows of a particular type. Therefore I started by writing some code that built a list of top-level windows using EnumWindows, then waited a few seconds, and then did it again. On the second pass the code printed all of the newly created windows. By running this program and then triggering the bug before the second pass I could see what new windows were created. There were quite a few, and the problem then became to sort out the interesting from the banal.

I focused on the window styles, obtained with a couple of calls to GetWindowLong:

LONG style = GetWindowLong(hwnd, GWL_STYLE);
LONG exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);

A bit of experimentation and staring at hexadecimal representations of window styles made me suspect that always-on-top windows (WS_EX_TOPMOST) were relevant. These are windows that have a flag that says that they should be on top of all ‘normal’ windows.

However my system contained quite a few always-on-top windows, so that clearly wasn’t enough. More playing around led me to notice a few common attributes. In all situations where the bug appeared there was a new window that was:

  1. Always-on-top (WS_EX_TOPMOST)
  2. Visible (WS_VISIBLE)
  3. Owned by ipoint.exe, sidebar.exe, or iexplore.exe
  4. Zero size and located at 0,0

With these factors identified I modified my code so that when it detected a window that fit these four attributes it would clear the WS_VISIBLE flag:

SetWindowLong(hwnd, GWL_STYLE, style & ~WS_VISIBLE);

And the bug went away! This simple fix – clearing a flag from these particular windows – fixes all known instances of this bug.

Celebration!

Changing the window styles of a window owned by another program is rude. It’s bad behavior. But, the idea of an always-on-top, visible, zero-sized window is illogical and, apparently, problematic, so I assuaged my conscience with something about the needs of the many users outweighing the needs of a few windows, and called it good.

The only remaining thing to do was to wrap this into a useful general purpose tool. I made the executive decision to fix all windows that had attributes 1, 2, and 4, regardless of what process they were owned by. I also decided to create a variation of the fixer tool that hangs around and runs the fix-it process every time the user presses tab.

The net effect is that if you run Cygnus Software’s Super Alt+Tab Fix-it Magic Ronco Latenight Infomercial Madness AltTabFixContinuous.exe then the bug should go away. Every time you type Alt+Tab (or, you know, just ‘tab’) any malformed windows are fixed before they can cause pain and suffering. Put this (did I mention it’s free!) program in your startup folder and this bug should (no warranty implied) go away.

You can also test it out with less of a commitment by running AltTabFixOnce.exe. This runs the fix-it process just once, and prints out the results so that you can see what it found and what it did.

Bad advice

In the answers.microsoft.com discussion there are many suggestions about how to deal with this bug and I’d like to respond to some of them here:

  • Turn off Aero Peek – this works, I guess, but turning off a feature hardly counts as fixing it
  • Check which version of Windows 7 you are running – this doesn’t matter, all versions are vulnerable
  • Update your display drivers – if this helps at all it is pure luck because the bug is not related to display drivers

The bug is in Windows Explorer. The Windows 7 version of Windows Explorer apparently doesn’t handle always-on-top windows very well.

In closing

imageThe programs that create zero-sized always-on-top windows should stop doing that. It’s just weird. But really, explorer should be able to handle it. In Windows 8 explorer appears to have been fixed in order to avoid this bug.

I’m not thrilled about having written this program. On the upside, I’m pleased to have the skills needed to identify the factors that cause this bug, and the time to create a tool that will automatically remove those factors. On the downside, what a waste of time. The bug has been known for years and it probably affects millions of people (a large and increasing percentage of Windows 7 users who use Alt+Tab). I really wish Microsoft would fix these fit-and-finish bugs, rather than hoping that customers upgrade to Windows 8. As a Microsoft stockholder I really wish that they would make make their products a delight to use. Maybe now that IE 10 is making the bug show up more frequently they will feel obliged to fix it – or at least fix IE 10 so that it doesn’t trigger the bug.

I have passed all of this information along to my informal contacts at Microsoft.

In short, if you are currently experiencing this bug and you want to test my fix, run AltTabFixOnce.exe, look at the output, and see if it works. If the fix appears to work and you want to be rid of this scourge forever then copy AltTabFixContinuous to your startup folder. Both programs, and their source code, are available here. That is all.

Resources

About these ads

About brucedawson

I'm a programmer, working for Google, focusing on optimization and reliability. Nothing's more fun than making code run 10x faster. Unless it's eliminating large numbers of bugs. I also unicycle. And play (ice) hockey. And juggle.
This entry was posted in Bugs, Computers and Internet, Investigative Reporting and tagged , . Bookmark the permalink.

34 Responses to Alt+Tab Bug Worsened by IE 10, But Fix Found

  1. jladams97 says:

    Amazing! It appears to do the trick for me. I’m an ipoint user (you mention that you don’t know what it does: if you have a Microsoft mouse, it gives it much greater configurability than does Windows alone).

  2. qwop says:

    I guess it is a mix of weird wndHandles and composition: Sometimes in my home computer, a contextual menu redraw gest stuck in my screen. Then killing the owner process doesn’t clear it. However, killing dwm.exe (the windows 7 composite manager) do clear it. This probably deserves one of those interesting Raymond Chen articles.

  3. Tyler says:

    “I guess, but turning off a feature hardly counts as fixing it” — could say the same about not using sidebar.exe or ipoint.exe

    • brucedawson says:

      Agreed. All previous fixes/workarounds to this bug required turning off some feature. I was lucky in that I didn’t care about ipoint.exe and sidebar.exe, but some people do.

  4. Pingback: Alt+Tab Depth Inversion Bug | Random ASCII

  5. Pingback: Other Causes of Alt+Tab Problems | Random ASCII

  6. movntdqa says:

    “The programs that create zero-sized always-on-top windows should stop doing that. It’s just weird.”

    Unfortunately, those are work-arounds for Windows APIs. I’ve seen several issues that could only be fixed with that, and several for which it was the simplest fix.

    • brucedawson says:

      I believe that zero-by-zero windows need to be created, but I’m not convinced that they need to be visible and always-on-top. Do you know if they do? Also, out of curiosity, do you know what issues these windows are used to fix?

      And of course, the real bug continues to be in Windows Explorer for not handling these.

  7. Bill Barto says:

    Thank you for the dogged determination to dig into the *real* reasons behind this. I too was sure it was something to do with always-on-top windows, but I don’t have the tools or the inclination to dig into like you did! I’ve noticed similar weirdness happens when you use the full-screen viewing options for some past versions of IE – after I did that, even my normal windows/start/toolbar wouldn’t scroll up correctly from the bottom. In summary, all previous versions of (windows) explorer have some sort of display bug with the always-on-top windows and this is just another incarnation of that now that more programs use those types of windows.

  8. Pingback: Defective Heat Sinks Causing Garbage Gaming | Random ASCII

  9. Peter Vredenburgh says:

    Didn’t fix a thing for me…

  10. Robin says:

    Instantly fixed for me! Thank you, this was driving me crazy but like others, I didn’t have the time to dedicate to finding a fix, although I would have loved to! I had previously fixed this by getting rid of ipoint.exe, although I agree disabling features is not a ‘fix’, the bug had reared it’s ugly head again recently and is now gone.

    One thing though, the file AltTabFixOnce.exe was flagged as a virus by my companies antivirus (F-Secure). I have a lot of respect for Valve and extended that to yourself so I figured I’d trust that this was a false-positive. AltTabFixContinuous.exe was not flagged as a virus.

    Props for including the source code too!

    • brucedawson says:

      I don’t know why AltTabFixOnce.exe is flagged as a virus. That’s frustrating. If in doubt you can always rebuild it from source.

      Keep in mind that this blog and those tools aren’t associated with Valve — I just happen to work there.

      • Robin says:

        No, I didn’t think the blog/tools were associated with Valve, but since you were associated with them I decided to trust that the AV was giving false positives (plus, I didn’t actually run the files flagged as malicious!). Normally, I wouldn’t have taken the risk of running executables downloaded from a blog that AV thought were suspicious.

        In case you were wondering, F-Secure flags it as “DeepScan:Generic.Malware.P!Pk!.28956A22″. It doesn’t mean much to me, but it’s a generic heuristic scan so it could be something a simple as the code structure. It’s not being flagged as any known virus or malware.

  11. SWB says:

    Bruce, this is awesome. I was plagued by the same problem for years. In fact, I didn’t even realize it was a bug, since my Windows 7 installs (all on ThinkPads) have always behaved this way. I assumed that’s the way Microsoft (stupidly) designed it to work. I finally became so annoyed with the behavior, though, that I went looking for a way to turn it off and found your article. In my case, the offending process (which I identified by running your AltTabFixOnce.exe) was tpnumlkd.exe, an on-screen NumLock display utility installed on ThinkPads (note: NOT a child process of ipoint.exe, sidebar.exe, or iexplore.exe). Your program fixed it right up, and I now have AltTabFixContinuous.exe on autorun. This made my day. Thanks!!!

  12. NetMage says:

    Since I only have this happen with Intellipoint and I don’t need it to run continuously, but I don’t want to have to hit enter every time I start, I created another version, AltTabFixOnceNoPause that doesn’t have the getc() call.

  13. Michel says:

    Hi,
    Congratulation. It seems to be a good and usefull job.
    BUT it is not working for me:
    After running AltTabFixOnce, I get the list of two explorer.exe and the following message “2 visible always-on-top windows fund, 0 fixed.”
    I tried to run it as admin but same result.
    Any hint ?
    Rgds,
    Michel

    • brucedawson says:

      If there aren’t any visible always-on-top windows to fix then my program can’t help you. Running as administrator won’t help. Your problem must have another cause. Sorry. Try reporting the problem to Microsoft.

      • Sai says:

        Microsoft ain’t gonna help one bit. I have the same problem after I installed new pc parts and tried to play a game full screen without it alt tab continuously, tried the fixer it didn’t fix it.

  14. crgolden says:

    Great work! Thank you so much. This bug has plagued me for years.

  15. Pingback: Bugs I Got Other Companies to Fix in 2013 | Random ASCII

  16. Pingback: Tweak Windows Alt+Tab switcher to enlarge thumbnails and disable live aero peek preview | Winaero

  17. A. Jung says:

    Based on your source code I created a modified version that also fixes this problem for avpui.exe (Kaspersky User Interface process).
    see: http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/alt-tab-window-wont-stay-on-top-of-other-windows/9795ed00-3e9f-4751-8e6b-da9a25e820e0?page=16

    I hope they are useful to others and I hope it’s OK that I released these modified versions.

    • brucedawson says:

      That’s great! Thanks for doing that, and thanks for letting me know.

      Is the Kaspersky window off-screen, or is it invisible for some other reason?

      • A. Jung says:

        I investigated a bit more about this problem.
        The Kaspersky window that causes the problem has the following properties:
        ————————————————————————————————
        title: ”
        class: ‘AVP.SandboxWindow’
        base class: ‘AVP.SandboxWindow’
        style: 94000000
        WS_POPUP WS_VISIBLE WS_CLIPSIBLINGS
        exStyle: 000800a8
        WS_EX_TOOLWINDOW WS_EX_TOPMOST WS_EX_TRANSPARENT WS_EX_LAYERED
        window rect: 0, 0 to 1366, 768
        window region type: NULLREGION
        process: avpui.exe
        ————————————————————————————————
        The screen size is 1366×768, i.e. it covers the whole screen.
        I checked on Win 7 and Win 8.1 and interestingly it breaks Alt+Tab on both versions, but on Windows 8.1 it additionally also breaks the taskbar live previews (they also appear behind windows instead of in front). So something between these windows versions changed that made the problem even worse.

        I don’t know what Kaspersky tries to achieve with that window. I verified that removing the visible or topmost flag has afaict no negative consequences. Everything that I tested still works (Main window, Settings window, other UI windows, info and virus warning messages) when these flags are unset on the above window. Whatever they tried to do, if it breaks basic Windows functionality that’s pretty bad. (Of course Windows is at fault here, too. Topmost visible windows should be correctly handled.)
        I will collect all info I have about this problem and report it to Kaspersly and we’ll see what they have to say about this.
        ————————————————————————————————
        Broken Alt-Tab: https://drive.google.com/file/d/0B-TTujCqmfzCUG83VXlCUloxcDQ/edit?usp=sharing
        Broken taskbar live previews: https://drive.google.com/file/d/0B-TTujCqmfzCVmk5dlU4MVIzbU0/edit?usp=sharing
        ————————————————————————————————
        Tool used to print additional details about all visible topmost windows:
        file selection download: https://drive.google.com/file/d/0B-TTujCqmfzCX3RoaTB6dGdQZFU/edit?usp=sharing
        zip download: https://docs.google.com/uc?id=0B-TTujCqmfzCX3RoaTB6dGdQZFU&export=download

  18. Matt says:

    Fixing alt+tab depth problems by clearing the visible flag on all
    zero by zero always-on-top visible windows.

    Listing all visible always-on-top windows.
    Title: ‘Start’ style: 94000c00 exStyle: 00080088 2, 1040 to 54, 1078, explor
    er.exe
    Title: ” style: 96840000 exStyle: 00000188 -2, 1036 to 1922, 1082, explorer
    .exe
    2 visible always-on-top windows found, 0 fixed.

    Alt+tab should now work correctly. To have this fix run every time
    you type Tab just copy AltTabFixContinuous.exe to your startup folder.
    This program is provided free of charge to fix the problems discussed here:

    http://randomascii.wordpress.com/2011/10/16/alttab-depth-inversion-bug/.

    Copyright 2013 Cygnus Software.
    Press enter to exit.

    seems to work at first then it stops???? but it also says here that 0 were fixed?

    • brucedawson says:

      In order to avoid causing problems my program only turns off the visible flag for 0×0 windows, so it leaves those two windows alone. It’s not a perfect heuristic, but I wanted to make sure I didn’t make things worse. In this case it decided there was nothing to do. Then it stopped, ’cause it was done. The source is available if you want to experiment with changing it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s