title: Get window handle of last activated window
body: <p>I am developing an application that sits in the system tray and can perform actions on the active window. But when the icon in the system tray is clicked, <code>GetForegroundWindow()</code> returns the taskbar. I need to get the window that was active before the taskbar was.</p>
  
  <p>I've tried enumerating the desktop window with <code>EnumWindows</code> and <code>GetWindow</code>, but this is often turning up desktop gadgets and other top items that where not active last. Is it even possible, or the information completely lost when the window is deactivated?</p>