How do I programmatically invoke Aero Peek on a window?

A customer wanted to know if there was a way for their application to invoke the Aero Peek feature so that their window appeared and all the other windows on the system turned transparent.

No, there is no such programmatic interface exposed. Aero Peek is a feature for the user to invoke, not a feature for applications to invoke so they can draw attention to themselves.

Yes, I realize you wrote a program so awesome that all other programs pale in comparison, and that part of your mission is to make all the other programs literally pale in comparison to your program.


Maybe you can meet up with that other program that is the most awesome program in the history of the universe and share your sorrows over a beer.

Comments (27)
  1. Cyrill says:

    What about using this supposed feature for writing shell replacement?

    [Then the question would have been "How do I invoke Aero Peek on some other window?" -Raymond]
  2. Medinoc says:

    You so need to create a "I bet somebody got a really nice bonus for that feature" tag.

  3. Adam Rosenfield says:

    So is there an API for invoking Aero Peek on another window?  If you were writing a shell replacement (or shell-like program), it'd be perfectly reasonable to want to draw a preview of one of your child windows when the mouse is over a particular portion of your program's window.

  4. Adam Rosenfield says:

    Err, replace "draw a preview of one of your child windows" with "make all but one of your child windows transparent like Aero Peek does".  I apparently confused my Aero features by failing to read properly.

  5. Leo Davidson says:

    It'd be handy if the DWM had an API for detecting when it's distorting a window. Not for doing the distortions but for knowing when they're being done (or when they start/stop).

    If you're doing something where what's shown in your window is supposed to match-up with screen coordinates (or have multiple windows acting in concert) it's useful to know if DWM is in the middle of an open/close/min/max animation and not really showing the window's pixels at the coordinates the OS says they're at.

    You can disable those animations for a window but that's throwing the baby out with the bathwater. :)

  6. Koro says:

    I wish there was an API to arbitrarily scale and/or transform the contents of a single DWM window though.

    "Some" apps don't play well with high-DPI, but I do not want to globally enable DPI scaling, would like to just be able to scale a specific window (Virtual PC comes as an example).

    I know the DWM can do it, it's a sad thing not more of its capabilities are exposed through APIs.

  7. chrismcb says:

    The first thing I do on a new system is turn the stupid Aero feature off. I don't need to see through my title bars. So then I install a new app, and it wants nice rounded corners, with a shadow… Ohhh and while we are at it, lets draw the title bar as transparent.

    So now I have one window that looks different than all the others, with a stupid transparent title bar. And of course it doesn't always draw properly. Sometimes part of the window shows on top of whatever window is over it. Why can't apps just play nice. If I wanted to be able to see through my title bars I would have turned the stupid aero look on.

  8. miniak says:
    [Undocumented functions deleted. -Raymond]
  9. Adam Rosenfield says:

    @miniak: It's people like you whose software breaks in the next version of Windows because you start poking around in undocumented functionality, and then Raymond has to write compatibility shims for you.

  10. Maurits says:

    Sure, just install a mouse filter driver and programmatically move the mouse pointer over your app's taskbar button.

  11. configurator says:

    How do I invoke Aero Peek on some *other* window?

    (note: I'm only asking that because you suggested it, Raymond. I still the ability to do that would most likely be used for evil rather than good)

    [That power would be used for evil. (See this post.) -Raymond]
  12. Dean Harding says:

    Since your app is so totally awesome, simply kill all other running processes. There's no need to be running anything else anyway. No need for Aero Peek either!

  13. Joshua says:

    > How do I invoke Aero Peek on some *other* window?

    Easy. Since you are the shell, you can hide all other windows and draw the outlines yourself.

  14. Cheong says:

    On the other hand, I think it would be awesome to implement Aero Peek like feature in MDI forms with icon like toolbar.

    While you can iterate your child window and set their Form.Opacity property or calling UpdateLayerWindow() API, the resulting effect is not quite as cool as Aero Peek IMO…

  15. Pete says:

    So glad MS learnt not to give API's to things like this. The number of apps that try to put themselves on startup is bad enough. User choice settings should be left to the user, glad their is no easy way to put apps on the W7 taskbar either "Although I discovered their is a hacky way in windows scripting".

  16. Nick says:


    Clearly MSDN blogs needs a +1, Evil moderation option.

    Of course, maybe a better option would be to install a second mouse* via some kind of virtual mouse driver which you can position at will.  That way you won't even disrupt the user while making sure they know how awesome your program is.  And even though you'll probably break every program that interacts with the mouse in any way, it's totally worth it because of the sweet bonus you'll get for it :)


  17. Gabe says:

    Maurits: In theory you shouldn't actually need to move the mouse pointer; you should be able to do it just by sending the right WM_MOUSE* messages to the right window.

  18. miniak says:

    Looks like it is not allowed here to mention undocumented functions… Sorry for that. I just wanted to point out that it is possible with some effort and the right tools.

    @Adam Rosenfield: I don't use this in any publicly available software. It's just my experiments. No one is going to get hurt :)

    @Raymond: At least the 2 functions which convert between the real window and its ghost window (when hung) could be public. I can image legitimate use for this (Process Explorer window selection tool would select the real process on hung windows, not the DWM…)

  19. Ken Bloom says:

    Microsoft shouldn't have undocumented API calls. If they really don't want anyone calling the APIs, they shouldn't export them in the first place.

  20. Kyle says:


    That's just unworkable because it requires them to write documentation for general consumption, not just internal use (which I would assume is much less stringent in its requirements).

  21. hidden APIs = unlawful APIs says:

    It's time to lobby EU to force MS releasing these undocumented APIs, as they did with SMB and other stuff.

  22. Gabe says:

    Ken Bloom: Are you suggesting that every single function export in every single DLL is a public API that needs to be documented and maintained in perpetuity? Because that's what it sounds like.

    Do you really believe that everything should be statically linked except for the few functions that are intended for public use?

  23. mh says:

    It's time to lobby EU to force MS releasing these undocumented APIs, as they did with SMB and other stuff.

    …and in 5 years time when everybody's PC is a screaming nightmare of misbehaving apps with the OS completely clogged by compatibility hacks you can sit back and smugly think "oh well, at least I did the right thing".

    Why pick on MS all the time anyway?  It's getting old and boring.  There are other software vendors you know.

  24. Marquess says:

    Microsoft shouldn't copy-protect its software. If they really don't want anybody to pirate it, they shouldn't release it in the first place.

    Seriously, though, one should keep in mind that the division between undocumented and documented APIs is for the benefit of the developers, not their detriment. It gives them an assurance that the documented calls will be available in future versions of the product, while providing a documented interface to any (sensible) parts of the OS — so there should be no need to use undocumented interfaces. If they didn't, that would indeed be a sad oversight *cough* NTFS defrag *cough*, but that doesn't make it a good idea to use undocumented interfaces.

  25. yuhong2 says:

    "Microsoft shouldn't copy-protect its software."

    I remember Bill Gates taking a stand against doing so.

    Anyway, I think it is probably because Marketing is thinking that you draw attention on a computer the same way you do on TV.

  26. Joshua says:


    Unfortunately my experience says the documented method may change, but the undocumented method continues to work.

    Specific example: custom security module API changed from GINA to Credential Provider but the undocumented method involving an undocumented API continued to work. It got broke once on Server 2003, but that turned out to being LocalSystem doesn't carry the required privilege anymore, so logging on as a super-privileged local user did the trick.

  27. Jorge Coelho says:

    [That power would be used for evil. (See this post.) -Raymond]

    Raymond, even a fork can be used for evil. So, do we ban forks and knives and eat with our hands? Of course not.

    It is up to the user to chose which applications he wants to run on his system. If an application misbehaves, or behaves in an evil way, the user has a choice NOT to run it. When Microsoft decides to play God and starts deciding for others what is evil and what isn't, it is limiting developers on what they can do and users on what they can run. Unless Microsoft then abides by their own rules (and we know they don't) then the only evil thing going on is Microsoft itself. But enough of the philosophical talk, lets give a *single* practical example:

    Hundreds of thousands of Windows users run 'docks' – we all know what a dock is by running or seeing videos of Apple's MacOSX dock (even though the concept of 'docks' was invented long before it). These dock applications are called 'shell enhancements', and *one* of their purposes is to replace or enhance the Windows taskbar (yes, even the mighty Windows 7 "superbar", which is, more and more, behaving like a dock – even though a very limited one because of Microsoft's 'one UI to suit all' approach; which I am not bashing, mind you, it is necessary).

    To replace the Windows taskbar you need to be able to list running applications, and, just as important, the Windows system tray (notification area). However, even though Microsoft has been very much aware of the existence of these shell enhancements for years, there is no public/documented API to, at the very least, enumerate notification items.

    The only way this can currently be accomplished is by reading Explorer's private memory and walking the undocumented notification area structure. This can – and will – break between different Windows versions, forcing developers to update their code every time a new Windows version is released (not a biggie).

    Now, if you are a developer making 'vanilla' Windows applications (and I don't mean this as an insult) it will be hard for you to understand why I think Raymond's and Microsoft's approach is wrong. If, on the other hand, you are a developer 'pushing the edge of what is possible' and constantly running into these roadblocks – and Microsoft's 'oh, that can be used for evil' attitude – which, unfortunately, can only be overcome by 'hacks' and resorting to undocumented APIs, you will understand very well what I mean.

    For a dock (and many other shell enhancement applications), a public and documented API for Aero Peek, which would be *user initiated*, would be very useful. Again, because Microsoft is playing God, we have to resort to undocumented calls like those Miniak described.

    Remember that it's those who think different and push the envelope of what is possible that make things evolve. Cutting their legs and then reproaching them because they have no choice but to resort to undocumented ways to accomplish their goals, is a bit stupid, IMO.

    [We've already seen what happens when you let things to be used for evil, and Windows is still trying to clean up the mess it created. -Raymond]

Comments are closed.